Anyone building software since the 1970s knows the Command Line Interface (CLI) well. Developers spend so much time crafting and running commands that it's easy to overlook the people behind the tools - but that work shapes how we interact with our systems every day!
We think about how people use our software every single day. Whether people use Bacalhau through the embedded UI, API, or CLI, creating an intuitive and delightful experience is something that we don't consider a nice-to-have but an absolute necessity.
To that end, we're introducing some updates to Bacalhau's CLI commands that we hope will help you get things done quicker and, hopefully, find delightful.
The --config Flag
In previous versions of Bacalhau, each installation has initialized a "repo" in the home directory of the installing user, where configuration settings and other bits and pieces used by Bacalhau have been stored. That hasn't changed, but we appreciate that having the ability to specify a path to a specific file can be useful for anyone that needs straightforward, repeatable configuration for their use cases.
With 1.5.0, we're introducing the --config
flag. When used, this flag will tell Bacalhau to look for configuration options at the passed path instead of the default configuration file (usually) found in ~/.bacalhau
.
It can be used as such:
bacalhau --config "~/my_config.yaml" serve --compute --orchestrator
Any configuration settings found in a file passed with --config
will override any default settings that Bacalhau has for those values. For settings that aren't found in the file passed, Bacalhau will still default to its hardcoded default values unless set otherwise.
This should enable developers to quickly apply and transfer settings for their Bacalhau installations per their needs.
The Key Value of key:value Pairs
With 1.5.0, we're also introducing the ability to use the --config
flag to pass individual parameters as key value pairs with the CLI.
Let's say you want to set the default API host of your Bacalhau nodes to point at the Bacalhau default network. Previously, you'd run something like:
bacalhau config set api.host bootstrap.demo.bacalhau.org
That works well if you only want your installation to connect to our demo network until you change it. But we know that when people are trying things out, they don’t want to keep setting and resetting values in their configuration. Now, you can set a config value for a single run with a command like the following:
# Set the api.host config value for this run
# and get a list of nodes from the public network
bacalhau --config api.host=bootstrap.demo.bacalhau.org node list
You can also use the -c flag to set individual values using key:value pairs.
# Set the WebUI to listen on port 4321 instead of 8483
# for connections
bacalhau serve --compute --orchestrator -c WebUI.Listen=:4321
To confirm that your configuration values are being set, you can run:
bacalhau config list
1, 2, 3, 4! Shipping and Merging Multiple Config Files
The config file sits at the heart of Bacalhau configuration, but to date, it has only been possible to have a single configuration file per instance of Bacalhau.
With 1.5.0, we’re introducing the ability to specify multiple configuration files via the CLI whenever you start a Bacalhau node. This enables more specialized, shareable configurations on a node-by-node basis.
To use more than one configuration file when launching Bacalhau, you can use the --config flag multiple times to specify the location of any configuration files you wish to use on your system.
bacalhau serve --compute --orchestrator -c base-config.yaml -c extra-config.yaml
When using multiple config files, the order matters. The first config file you pass with the --config
flag becomes the base for your node, overriding Bacalhau’s default settings where applicable.
Subsequent config files passed with --config
will override the values in previously defined configuration files if there is a conflict.
Let’s take a look at the previous example:
bacalhau serve --compute -c base-config.yaml -c extra-config.yaml
When the Bacalhau compute node starts, the base-config.yaml
file will serve as the first location Bacalhau will look for configurations from. If a value in base-config.yaml is different from the default, it will be set as the value for this execution.
However, if extra-config.yaml
is setting that same value, it will override that setting’s value in base-config.yaml
. This pattern continues until all of the --config
flags and files passed have been processed.
If you want to see the ultimate configuration of passing multiple config files to Bacalhau, you can print it out in your console with the config list command:
bacalhau config list -c ./config-1.yaml -c ./config-2.yaml —output yaml
You Complete Me - Introducing Command Autocomplete
You may have noticed that Bacalhau has a lot of configuration options. That’s because we want Bacalhau to be as flexible as possible when people are trying to build out their projects. However, it can be tough to find the exact setting you’re after, especially when you may need to set more than one or two every now and then.
With 1.5.0, we’re introducing configuration autocomplete!
After an initial setup, whenever you’re configuring an option, you can tab to see all of the settings available to you based on your input so far.
To set up configuration autocompletion, you can follow these steps:
# Generate the autocomplete script for your system
bacalhau completion <bash|zsh> /tmp/bacalhau_autocomplete && source /tmp/bacalhau_autocomplete
# Use your OS's package manager to use autocomplete for all
# new sessions using the 'bash-completion' package.
#### Linux:
bacalhau completion bash > /etc/bash_completion.d/bacalhau
#### macOS:
bacalhau completion bash > $(brew --prefix)/etc/bash_completion.d/bacalhau
You will need to start a new shell for this setup to take effect.
Conclusion
With these changes, we hope that you’ll find Bacalhau easier to configure than ever before. It’s incredibly important to us that people find interacting with Bacalhau straightforward and intuitive, so if you have any thoughts/feedback/ideas, let us know - we always love to hear from our users.