Skip to content

Conversation

wfchandler
Copy link
Collaborator

It can be convenient to select the silo to target via the environment. We have the OXIDE_HOST and OXIDE_TOKEN env vars today, but these require putting your private token in the environment.

Add a new OXIDE_PROFILE env var which accepts just the profile name from credentials.toml. To avoid confusion around precedence between this and OXIDE_HOST, return an error if both are set.

Closes #1080

It can be convenient to select the silo to target via the environment.
We have the `OXIDE_HOST` and `OXIDE_TOKEN` env vars today, but these
require putting your private token in the environment.

Add a new `OXIDE_PROFILE` env var which accepts just the profile name
from `credentials.toml`. To avoid confusion around precedence between
this and `OXIDE_HOST`, return an error if both are set.

Closes #1080
@wfchandler
Copy link
Collaborator Author

This conforms to the chart in #1080 (comment), with the exception that --profile overrides both OXIDE_HOST and OXIDE_PROFILE, and the latter two are mutually exclusive.

@wfchandler wfchandler requested a review from ahl September 30, 2025 17:24
Copy link
Collaborator

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Do we want to add documentation... somewhere? Perhaps in the help output or in cli/README.md? I'm not sure if we want that table from #1080 exactly or just something like that.

Comment on lines +191 to +193
if std::env::var("OXIDE_HOST").is_ok() && std::env::var("OXIDE_PROFILE").is_ok() {
return Err(OxideAuthError::HostProfileConflict);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could do something with clap's parsing to examine env vars... but I'm not sure that would be better; just noting it in case it seems worthwhile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about adding OXIDE_PROFILE to just the CLI, which would let easy to do with Arg::env, as you say. This seems like something that would be generally convenient, so I went with including it in the SDK.

&ClientConfig::default().with_host_and_token(&host_env, &token_env),
)
.expect("client authentication from host/token failed");
)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the new behavior in these cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this path was in practice infallible, now it can fail if OXIDE_HOST and OXIDE_PROFILE are both set. With the expect we get a somewhat confusing panic here:

$ OXIDE_HOST=a OXIDE_TOKEN=b OXIDE_PROFILE=c cargo run -- auth status
thread 'main' panicked at cli/src/cmd_auth.rs:501:14:
client authentication from host/token failed: HostProfileConflict

wfchandler and others added 2 commits October 7, 2025 17:38
Co-authored-by: Adam Leventhal <[email protected]>
Co-authored-by: Adam Leventhal <[email protected]>
@wfchandler wfchandler merged commit 87432ce into main Oct 7, 2025
17 checks passed
@wfchandler wfchandler deleted the wc/oxide-profile-env branch October 7, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

should be able to select a profile via the environment
2 participants