From 8bf69cbaa894adfc87925f40d26777c7e8152566 Mon Sep 17 00:00:00 2001 From: Andrew McClenaghan Date: Wed, 21 Apr 2021 02:35:07 +1000 Subject: [PATCH] feat(aws): Add support for profile from awsume (#2609) --- docs/config/README.md | 3 +++ src/modules/aws.rs | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/config/README.md b/docs/config/README.md index 643867c6..3d93396f 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -257,6 +257,9 @@ is read from the `AWS_VAULT` env var. When using [awsu](https://github.com/kreuzwerker/awsu) the profile is read from the `AWSU_PROFILE` env var. +When using [AWSume](https://awsu.me) the profile +is read from the `AWSUME_PROFILE` env var. + ### Options | Option | Default | Description | diff --git a/src/modules/aws.rs b/src/modules/aws.rs index 72a57f72..637ecc7f 100644 --- a/src/modules/aws.rs +++ b/src/modules/aws.rs @@ -47,7 +47,7 @@ fn get_aws_region_from_config(context: &Context, aws_profile: Option<&str>) -> O } fn get_aws_profile_and_region(context: &Context) -> (Option, Option) { - let profile_env_vars = vec!["AWSU_PROFILE", "AWS_VAULT", "AWS_PROFILE"]; + let profile_env_vars = vec!["AWSU_PROFILE", "AWS_VAULT", "AWSUME_PROFILE", "AWS_PROFILE"]; let profile = profile_env_vars .iter() .find_map(|env_var| context.get_env(env_var)); @@ -214,6 +214,20 @@ mod tests { assert_eq!(expected, actual); } + #[test] + fn profile_set_from_awsume() { + let actual = ModuleRenderer::new("aws") + .env("AWSUME_PROFILE", "astronauts-awsume") + .env("AWS_PROFILE", "astronauts-profile") + .collect(); + let expected = Some(format!( + "on {}", + Color::Yellow.bold().paint("☁️ astronauts-awsume ") + )); + + assert_eq!(expected, actual); + } + #[test] fn profile_and_region_set() { let actual = ModuleRenderer::new("aws")