Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed May 23, 2024
1 parent 6fd3cb4 commit dd2eda9
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,31 @@ You can control output via the `-o` option:
The template’s input is the resource’s corresponding struct in the
[hcloud-go](https://godoc.org/github.com/hetznercloud/hcloud-go/hcloud) library.

## Configure hcloud using environment variables

You can use the following environment variables to configure `hcloud`:

* `HCLOUD_TOKEN`
* `HCLOUD_CONTEXT`
* `HCLOUD_CONFIG`

When using `hcloud` in scripts, for example, it may be cumbersome to work with
contexts. Instead of creating a context, you can set the token via the `HCLOUD_TOKEN`
environment variable. When combined with tools like [direnv](https://direnv.net), you
can configure a per-directory context by setting `HCLOUD_CONTEXT=my-context` via `.envrc`.
## Configuring hcloud

The hcloud CLI tool allows configuration using following methods:
1. Configuration file
2. Environment variables
3. Command line flags

A higher number means a higher priority. For example, a command line flag will
always override an environment variable.

The configuration file is located at `~/.config/hcloud/cli.toml` by default
(On Windows: `%APPDATA%\hcloud\cli.toml`). You can change the location by setting
the `HCLOUD_CONFIG` environment variable or the `--config` flag. The configuration file
stores global preferences, the currently active context, all contexts and
context-specific preferences. Contexts always store a token and can optionally have
additional preferences which take precedence over the globally set preferences.

However, a config file is not required. If no config file is found, the CLI will
use the default configuration. Overriding options using environment variables allows
hcloud CLI to function in a stateless way. For example, setting `HCLOUD_TOKEN` is
already enough in many cases.

You can use the `hcloud config` command to manage your configuration, for example
to get, list, set and unset configuration options and preferences. You can view a list
of all available options and preferences by running `hcloud config --help`.

## Examples

Expand Down

0 comments on commit dd2eda9

Please sign in to comment.