1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-09-28 05:09:01 +00:00

fix(aws): Make AWS_REGION orverrides AWS_DEFAULT_REGION (#3619) (#3733)

* 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:
kuno 2022-03-15 05:49:23 +08:00 committed by GitHub
parent 848bf693a4
commit 59622bc41b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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>) {
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
.iter()
.find_map(|env_var| context.get_env(env_var));
let region = context
.get_env("AWS_DEFAULT_REGION")
.or_else(|| context.get_env("AWS_REGION"));
let region = region_env_vars
.iter()
.find_map(|env_var| context.get_env(env_var));
match (profile, region) {
(Some(p), Some(r)) => (Some(p), Some(r)),
(None, Some(r)) => (None, Some(r)),
@ -285,7 +286,7 @@ mod tests {
.collect();
let expected = Some(format!(
"on {}",
Color::Yellow.bold().paint("☁️ (ap-northeast-1) ")
Color::Yellow.bold().paint("☁️ (ap-northeast-2) ")
));
assert_eq!(expected, actual);