b
is a binary or a Go package that provides a set of utilities for managing and executing binary files. It is particularly useful for binaries hosted on GitHub.
The package includes a Binary
struct that represents a binary file, including its name, file path, version, and other related properties. You can create a Binary
struct by providing the binary name and version, and then use the EnsureBinary
method to ensure that the binary is available on the system.
# Initialise a new project with b.yaml config and direnv
# (tip) init is optional; you use b without it
b init
# List all configured binaries
b list
b ls
# Install specific binaries
b install jq
b i kubectl helm
# Install and add binary to config
b install --add jq@1.7
# Install with alias
b i --alias envsubst renvsubst
# Update all binaries
b update
b u tilt
# Update specific binaries
b update jq kubectl
# Search for available binaries
b search terraform
b s kube
# Show version
b version
b v kind
# Request a new binary
b request
b
needs one of three things defined to know where to install binaries:
PATH_BIN
env, set to the directory where you want to install binaries.PATH_BASE
env, set to the project root directory. All binaries will be installed in the.bin
directory.- If you are in a git repository,
b
will install binaries in the.bin
directory in the root of the repository.
If none of these are set, b
will fail.
To properly use the --all
flag, you should create a b.yaml
file in the binary directory. This file should contain a list of binaries you want to manage. Here is an example:
binaries:
jq:
# pin version
version: jq-1.8.1
kind:
tilt:
# alias to renvsubst
envsubst:
alias: renvsubst
This will ensure that jq
, kind
, renvsubst
and tilt
are installed and at the correct version. If you don't specify a version, b
will install the latest version.
Note that renvsubst
is installed as envsubst
.
You can run b
using Docker without installing it locally:
# Run b with volume mount to access .bin directory
docker run --rm -v ./.bin:/.bin ghcr.io/fentas/b list
# Install binaries using Docker
docker run --rm -v ./.bin:/.bin ghcr.io/fentas/b install b jq kubectl
You can also copy the b
binary into your own Docker images:
FROM alpine:latest
# Copy the b binary from the official image
COPY --from=ghcr.io/fentas/b:latest /b /usr/local/bin/b
# Install binaries during build
ENV PATH_BIN=/usr/local/bin
RUN b install curl jq
# Your application code
COPY . /app
WORKDIR /app
All related documentation, including the source for the website, is located on the docs
branch.
If you have Go installed, you can build and install the latest version of b
with:
go install github.com/fentas/b/b@latest
Binaries built in this way do not have the correct version embedded. Use our prebuilt binaries or check out .goreleaser.yaml to learn how to embed it yourself.
To use this package, you need to import it into your Go project:
import "github.com/fentas/b/pkg/binary"
The Binary
struct represents a binary file, including its name, file path, version, and other related properties. You can create a Binary
struct by providing the binary name and version:
bin := binary.Binary{Name: "mybinary", Version: "1.0.0"}
bin.EnsureBinary(true)
Have a look at pkg/binary for more details.
Have a look at pkg/binaries for prepackaged binaries.
- argocd - Declarative Continuous Deployment for Kubernetes
- argsh - Utilities for Bash script quality
b
- (Selfupdate) Manage and execute binary files- cilium - Providing, securing, and observing network connectivity between workloads
- clusterctl - Kubernetes cluster lifecycle management
- curl - Command-line tool for transferring data with URL syntax
- docker-compose - Define and run multi-container Docker applications
- gh - GitHub CLI wrapper
- hcloud - Hetzner Cloud CLI wrapper
- hubble - Fully distributed networking and security observability platform
- jq - Command-line JSON processor
- k9s - Kubernetes CLI to manage your clusters
- kind - Kubernetes IN Docker
- kubectl - Kubernetes CLI to manage your clusters
- kubectl-cnpg - CloudNativePG kubectl plugin to manage PostgreSQL databases
- kubelogin - int128 - kubectl plugin for Kubernetes OpenID Connect authentication (kubectl oidc-login)
- kubeseal - A Kubernetes controller and tool for one-way encrypted Secrets
- kustomize - Kubernetes native configuration management
- mkcert - Create locally-trusted development certificates
- packer - Packer is a tool for creating machine and container images
- renvsubst - envsubst with some extra features written in Rust
- sops - Secure processing of configuration files
- ssh-to-age - Convert SSH Ed25519 keys to age keys
- stern - Simultaneous log tailing for multiple Kubernetes pods and containers
- tilt - Local Kubernetes development with no stress
- yq - Command-line YAML processor
Feel free to extend this, PRs are welcome.
Using direnv allows you to load required binaries bound to a specific project.
#!/usr/bin/env bash
set -euo pipefail
: "${PATH_BASE:="$(git rev-parse --show-toplevel)"}"
: "${PATH_BIN:="${PATH_BASE}/.bin"}"
export PATH_BASE PATH_BIN
This is all you need; alternatively, you can refer to here.
- Recognise the operating system and architecture and offer the correct binary (Windows support)
- Update docs
- Extends tests
- Advanced configurations, e.g. Proxy
b
is released under the MIT license, which grants the following permissions:
- Commercial use
- Distribution
- Modification
- Private use
For more convoluted language, see the LICENSE. Let's build a better Bash experience together.
Thanks to all tools and projects that developing this project made possible.
Copyright © 2024-present fentas