diff --git a/src/assume/mod.rs b/src/assume/mod.rs index e36bfde..fdf1363 100644 --- a/src/assume/mod.rs +++ b/src/assume/mod.rs @@ -44,12 +44,13 @@ fn run_raw(profile: &str, config: &Config) -> Result<(), String> { let mut assumer = RoleAssumer::new(config.region.clone(), &mut cred_file, config); assumer.assume(profile)?; print_profile(profile, config); - if Utc::now() - state.last_version_check_time - > Duration::days(config.check_new_version_interval_days as i64) - { - check_newer_version(); - state.last_version_check_time = Utc::now(); - state.save()?; + + if let Some(check_every_days) = config.check_new_version_interval_days { + if Utc::now() - state.last_version_check_time > Duration::days(check_every_days as i64) { + check_newer_version(); + state.last_version_check_time = Utc::now(); + state.save()?; + } } main_credentials::rotate_if_needed(config, &mut cred_file, &mut state)?; diff --git a/src/config.rs b/src/config.rs index a605e24..0161c88 100644 --- a/src/config.rs +++ b/src/config.rs @@ -17,7 +17,7 @@ pub struct Config { mfa_serial_number: String, mfa_command: Option, pub profiles: LinkedHashMap, - pub check_new_version_interval_days: u32, + pub check_new_version_interval_days: Option, pub modify_shell_prompt: bool, pub region: Region, session_name: String, @@ -108,7 +108,7 @@ impl Config { ) }) .collect(), - check_new_version_interval_days: rc.check_new_version_interval_days.unwrap_or(7), + check_new_version_interval_days: rc.check_new_version_interval_days, modify_shell_prompt: rc.modify_shell_prompt.unwrap_or(true), region, session_name: rc.session_name.unwrap_or_else(|| "awscredx".to_owned()), diff --git a/src/init/templates/config.toml b/src/init/templates/config.toml index 3020710..6c877b3 100644 --- a/src/init/templates/config.toml +++ b/src/init/templates/config.toml @@ -21,7 +21,8 @@ mfa_serial_number = "arn:aws:iam::MAIN_ACCOUNT_ID:mfa/USERNAME" # mfa_command = "ykman oath accounts code | awk '/SOME_PATTERN/ {print $2}'" # How often to check for new version. -check_new_version_interval_days = 7 +# Comment out to disable. +check_new_version_interval_days = 30 # This will prepend the assumed profile and the expiration time to your shell prompt. # You can disable this feature and directly use environment variable `AWS_PROFILE` with