Created
November 13, 2022 22:31
-
-
Save offbyone/2c48706be64ae4fd82f84b06d6467b65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn get_profile_or_default(aws_profile: Option<Profile>) -> Profile { | |
match aws_profile { | |
Some(p) => p.clone(), | |
None => "default".to_string() as Profile, | |
} | |
} | |
fn has_credential_process_or_sso( | |
context: &Context, | |
aws_profile: &Option<Profile>, | |
aws_config: &AwsConfigFile, | |
aws_creds: &AwsCredsFile, | |
) -> Option<bool> { | |
let config = get_config(context, aws_config)?; | |
let credentials = get_creds(context, aws_creds)?; | |
let empty_section = ini::Properties::new(); | |
let credential_profile = Some(get_profile_or_default(*aws_profile)); | |
let config_section = | |
get_profile_config(config, &credential_profile).or_else(|| Some(&empty_section))?; | |
let credential_section = credentials | |
.section(credential_profile) | |
.or_else(|| Some(&empty_section))?; | |
Some( | |
config_section.contains_key("credential_process") | |
|| config_section.contains_key("sso_start_url") | |
|| credential_section.contains_key("credential_process") | |
|| credential_section.contains_key("sso_start_url"), | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment