Skip to content

Commit 1390036

Browse files
davidknaVolatus
andauthored
fix(aws): support official AWS_SHARED_CREDENTIALS_FILE variable (starship#4242)
* fix(aws): use AWS_SHARED_CREDENTIALS_FILE instead Signed-off-by: Ismayil Mirzali <[email protected]> * fix tests & keep support for older variant Signed-off-by: Ismayil Mirzali <[email protected]> Co-authored-by: Ismayil Mirzali <[email protected]>
1 parent 53c1093 commit 1390036

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/modules/aws.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ type AwsCredsFile = OnceCell<Option<Ini>>;
1919

2020
fn get_credentials_file_path(context: &Context) -> Option<PathBuf> {
2121
context
22-
.get_env("AWS_CREDENTIALS_FILE")
22+
.get_env("AWS_SHARED_CREDENTIALS_FILE")
23+
.or_else(|| context.get_env("AWS_CREDENTIALS_FILE"))
2324
.and_then(|path| PathBuf::from_str(&path).ok())
2425
.or_else(|| {
2526
let mut home = context.get_home()?;
@@ -428,7 +429,7 @@ mod tests {
428429

429430
assert!(ModuleRenderer::new("aws")
430431
.env(
431-
"AWS_CREDENTIALS_FILE",
432+
"AWS_SHARED_CREDENTIALS_FILE",
432433
config_path.to_string_lossy().as_ref(),
433434
)
434435
.collect()
@@ -667,6 +668,15 @@ expiration={}
667668
)?;
668669

669670
let actual = ModuleRenderer::new("aws")
671+
.env("AWS_PROFILE", "astronauts")
672+
.env("AWS_REGION", "ap-northeast-2")
673+
.env(
674+
"AWS_SHARED_CREDENTIALS_FILE",
675+
credentials_path.to_string_lossy().as_ref(),
676+
)
677+
.collect();
678+
679+
let actual_variant = ModuleRenderer::new("aws")
670680
.env("AWS_PROFILE", "astronauts")
671681
.env("AWS_REGION", "ap-northeast-2")
672682
.env(
@@ -675,6 +685,11 @@ expiration={}
675685
)
676686
.collect();
677687

688+
assert_eq!(
689+
actual, actual_variant,
690+
"both AWS_SHARED_CREDENTIALS_FILE and AWS_CREDENTIALS_FILE should work"
691+
);
692+
678693
// In principle, "30m" should be correct. However, bad luck in scheduling
679694
// on shared runners may delay it. Allow for up to 2 seconds of delay.
680695
let possible_values = ["30m", "29m59s", "29m58s"];
@@ -830,7 +845,7 @@ aws_secret_access_key=dummy
830845
.env("AWS_PROFILE", "astronauts")
831846
.env("AWS_REGION", "ap-northeast-2")
832847
.env(
833-
"AWS_CREDENTIALS_FILE",
848+
"AWS_SHARED_CREDENTIALS_FILE",
834849
credentials_path.to_string_lossy().as_ref(),
835850
)
836851
.collect();

0 commit comments

Comments
 (0)