mirror of
https://github.com/starship/starship.git
synced 2024-12-26 17:18:49 +01:00
* fix(aws): Make AWS_REGION orverrides AWS_DEFAULT_REGION (#3619) * fix(aws): Align the coding style of region and profile env var (#3619)
This commit is contained in:
parent
848bf693a4
commit
59622bc41b
@ -64,12 +64,13 @@ fn get_aws_region_from_config(context: &Context, aws_profile: Option<&str>) -> O
|
|||||||
|
|
||||||
fn get_aws_profile_and_region(context: &Context) -> (Option<Profile>, Option<Region>) {
|
fn get_aws_profile_and_region(context: &Context) -> (Option<Profile>, Option<Region>) {
|
||||||
let profile_env_vars = vec!["AWSU_PROFILE", "AWS_VAULT", "AWSUME_PROFILE", "AWS_PROFILE"];
|
let profile_env_vars = vec!["AWSU_PROFILE", "AWS_VAULT", "AWSUME_PROFILE", "AWS_PROFILE"];
|
||||||
|
let region_env_vars = vec!["AWS_REGION", "AWS_DEFAULT_REGION"];
|
||||||
let profile = profile_env_vars
|
let profile = profile_env_vars
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|env_var| context.get_env(env_var));
|
.find_map(|env_var| context.get_env(env_var));
|
||||||
let region = context
|
let region = region_env_vars
|
||||||
.get_env("AWS_DEFAULT_REGION")
|
.iter()
|
||||||
.or_else(|| context.get_env("AWS_REGION"));
|
.find_map(|env_var| context.get_env(env_var));
|
||||||
match (profile, region) {
|
match (profile, region) {
|
||||||
(Some(p), Some(r)) => (Some(p), Some(r)),
|
(Some(p), Some(r)) => (Some(p), Some(r)),
|
||||||
(None, Some(r)) => (None, Some(r)),
|
(None, Some(r)) => (None, Some(r)),
|
||||||
@ -285,7 +286,7 @@ mod tests {
|
|||||||
.collect();
|
.collect();
|
||||||
let expected = Some(format!(
|
let expected = Some(format!(
|
||||||
"on {}",
|
"on {}",
|
||||||
Color::Yellow.bold().paint("☁️ (ap-northeast-1) ")
|
Color::Yellow.bold().paint("☁️ (ap-northeast-2) ")
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
Loading…
Reference in New Issue
Block a user