Skip to main content

Overview

When you work with more than one hoop installation (for example dev, 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:
  1. It saves the current config.toml back into the context you leave, so a hoop login made there is kept.
  2. It writes the target context into $HOME/.hoop/config.toml, in the format every hoop CLI reads.
  3. It installs and activates the CLI version that the target gateway runs, as hoop versions sync does.
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:
  1. Go to Organization > Settings > Experimental.
  2. Toggle experimental.cli_contexts to On.
The CLI reads the flag from the target gateway, with the target context’s login, every time you run 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

To log in with your identity provider instead of an API key, create the context without --api-key, switch to it, then run hoop login. The next switch saves that login into the context.

hoop context create

Without --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

The * marks the active context. LOGGED IN shows whether the context has a login.

hoop context show

The token is never printed.

hoop context use

What use does depends on the answer of the target gateway: The refusals tell you what to do:
After a switch without a login:

A configuration no context keeps

If config.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

Removing the active context needs --force. $HOME/.hoop/config.toml stays as it is.

File layout

A context file has the same keys as 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_GRPCURL and HOOP_TOKEN are all set, the other hoop commands use them instead of config.toml. Unset them to use the active context.
  • Two hoop context commands 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