diff --git a/Cargo.lock b/Cargo.lock index b53d7c8..e05ca95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "awscredx" -version = "0.8.0" +version = "0.8.1" dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -80,7 +80,7 @@ dependencies = [ "rusoto_sts 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "webbrowser 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 191c64a..dd20def 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "awscredx" -version = "0.8.0" +version = "0.8.1" authors = ["Alexei Samokvalov "] edition = "2018" diff --git a/src/assume/assumer.rs b/src/assume/assumer.rs index b4492a5..b0a93af 100644 --- a/src/assume/assumer.rs +++ b/src/assume/assumer.rs @@ -10,7 +10,7 @@ use crate::credentials::{CredentialsFile, ProfileName}; pub struct RoleAssumer<'a> { region: Region, - store: CredentialsFile, + store: &'a mut CredentialsFile, config: &'a Config, } @@ -31,7 +31,7 @@ impl From<&AwsCredentials> for Cred { } impl<'a> RoleAssumer<'a> { - pub fn new(region: Region, store: CredentialsFile, config: &'a Config) -> Self { + pub fn new(region: Region, store: &'a mut CredentialsFile, config: &'a Config) -> Self { Self { region, store, diff --git a/src/assume/mod.rs b/src/assume/mod.rs index 8a06c6c..619e16d 100644 --- a/src/assume/mod.rs +++ b/src/assume/mod.rs @@ -35,14 +35,11 @@ pub fn run(profile: &str, config: &Config) { fn run_raw(profile: &str, config: &Config) -> Result<(), String> { let mut cred_file = CredentialsFile::read_default()?; - let mut state = state::State::read(); - main_credentials::rotate_if_needed(config, &mut cred_file, &mut state)?; - let mut assumer = RoleAssumer::new( config.region.clone(), - cred_file, + &mut cred_file, config, ); assumer.assume(profile)?; @@ -52,6 +49,9 @@ fn run_raw(profile: &str, config: &Config) -> Result<(), String> { state.last_version_check_time = Utc::now(); state.save()?; } + + main_credentials::rotate_if_needed(config, &mut cred_file, &mut state)?; + Ok(()) } diff --git a/src/main.rs b/src/main.rs index 6a84979..60f97fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,3 @@ -extern crate ansi_term; -extern crate chrono; -extern crate clap; -extern crate custom_error; -extern crate hyper; -extern crate hyper_proxy; -extern crate hyper_tls; -extern crate linked_hash_map; -extern crate reqwest; -extern crate rusoto_core; -extern crate rusoto_credential; -extern crate rusoto_iam; -extern crate rusoto_sts; -extern crate serde; -extern crate serde_json; -extern crate serde_urlencoded; -extern crate toml; -extern crate webbrowser; - use std::env; use ansi_term::{Color, Style};