Overview
When you work with more than one hoop installation (for exampledev, stg and prd), switching usually means hoop config create, hoop login and hoop versions sync again, and the login of the installation you leave is lost.
A context saves one installation: its API URL, gRPC URL, TLS CA and login. hoop context use <name> switches the CLI to it in one command:
- It saves the current
config.tomlback into the context you leave, so ahoop loginmade there is kept. - It writes the target context into
$HOME/.hoop/config.toml, in the format every hoop CLI reads. - It installs and activates the CLI version that the target gateway runs, as
hoop versions syncdoes.
hoop context needs CLI 1.300.0 or later. To get it, run hoop versions upgrade.
Turn it on in each organization
hoop context use is behind the experimental flag experimental.cli_contexts. It is off by default. Each gateway holds the flag for its own organization, so an admin of each installation you switch to turns it on:
- Go to Organization > Settings > Experimental.
- Toggle
experimental.cli_contextsto On.
hoop context use. A context with no valid login gives the CLI no organization to ask, so use switches to it without reading the flag and without the version sync. Run hoop login, then hoop context use again to read the flag and sync.
If
experimental.cli_contexts is not listed in Settings > Experimental, the gateway is older than 1.300.0. Upgrade the gateway first: an older gateway cannot turn the flag on, so hoop context use refuses its contexts.create, list, show and remove only read and write files on your machine, so they work without the flag.
Quick start
--api-key, switch to it, then run hoop login. The next switch saves that login into the context.
hoop context create
--api-url, the context copies the current $HOME/.hoop/config.toml, login included, and becomes the active context. Use this once to save the installation you already use.
With --api-url, the context uses the values you pass.
Context names use 1 to 64 lower-case letters, digits,
., _ or -, and start with a letter or a digit. current is reserved.
You cannot replace the active context with --api-url ... --overwrite: its login lives in config.toml and the next switch would save it back. Switch to another context first, or log in again with hoop login.
hoop context list
* marks the active context. LOGGED IN shows whether the context has a login.
hoop context show
hoop context use
What
use does depends on the answer of the target gateway:
The refusals tell you what to do:
A configuration no context keeps
Ifconfig.toml points at an installation that no context saves (for example after hoop config create), use refuses, so that login is not lost:
hoop context remove
--force. $HOME/.hoop/config.toml stays as it is.
File layout
config.toml. Older CLIs never read contexts/, and they keep working with the config.toml that hoop context use writes.
Caveats
- When
HOOP_APIURL,HOOP_GRPCURLandHOOP_TOKENare all set, the other hoop commands use them instead ofconfig.toml. Unset them to use the active context. - Two
hoop contextcommands that change files wait for each other, so running them in two terminals at the same time is safe.
Next Steps
hoop versions
How the CLI installs and switches its own versions
CLI Reference
Full CLI installation, authentication, and configuration guide