-
Notifications
You must be signed in to change notification settings - Fork 18
Use OXIDE_PROFILE env var to select profile #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,6 +188,10 @@ impl Client { | |
.. | ||
} = config; | ||
|
||
if std::env::var("OXIDE_HOST").is_ok() && std::env::var("OXIDE_PROFILE").is_ok() { | ||
return Err(OxideAuthError::HostProfileConflict); | ||
} | ||
Comment on lines
+191
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about adding |
||
|
||
let (host, token) = match auth_method { | ||
AuthMethod::DefaultProfile => get_profile_auth(config_dir, None)?, | ||
AuthMethod::Profile(profile) => get_profile_auth(config_dir, Some(profile))?, | ||
|
@@ -296,6 +300,8 @@ fn get_profile_auth( | |
.next() | ||
.ok_or(OxideAuthError::MissingToken(env_host))? | ||
.clone() | ||
} else if let Ok(env_profile) = std::env::var("OXIDE_PROFILE") { | ||
env_profile | ||
} else { | ||
let config_path = config_dir.join("config.toml"); | ||
let contents = std::fs::read_to_string(&config_path).map_err(|e| { | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
andOXIDE_PROFILE
are both set. With theexpect
we get a somewhat confusing panic here: