Skip to content

Commit

Permalink
fix: ineffective region and endpoint profile entry
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxt committed Apr 5, 2023
1 parent 6bdd3ab commit 11e9e7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl AuthArgs {
.map(get_endpoint_by_region)
.map(Cow::Owned)
})
.or_else(|| auth_config.and_then(|c| c.endpoint.as_ref().map(Cow::from)))
.or_else(|| auth_config.and_then(|c| c.endpoint_config.as_ref().map(Cow::from)))
.unwrap_or(Cow::Borrowed(DEFAULT_ENDPOINT)),
token: match (self.token.as_deref(), auth_config) {
(Some(token), _) => Some(Cow::Borrowed(token)),
Expand Down
5 changes: 4 additions & 1 deletion src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,19 @@ impl Config {
}
}


#[derive(Debug, Deserialize)]
pub(crate) struct AuthConfig {
pub endpoint: Option<EndpointConfig>,
#[serde(flatten)]
pub endpoint_config: Option<EndpointConfig>,
pub key: Option<String>,
pub token: Option<String>,
pub headers: Option<Vec<(String, String)>>,
pub proxy: Option<String>,
}

#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub(crate) enum EndpointConfig {
Endpoint { endpoint: String },
Region { region: String },
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn main() -> color_eyre::eyre::Result<()> {
auth.region.as_deref().or_else(||
config.as_ref().and_then(
|c| c.auth.as_ref().and_then(
|a| a.endpoint.as_ref().and_then(
|a| a.endpoint_config.as_ref().and_then(
|e| if let EndpointConfig::Region { ref region } = e {
Some(region.as_str())
} else {
Expand Down

0 comments on commit 11e9e7e

Please sign in to comment.