Skip to content

Commit

Permalink
fix: main profile credentials rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
sam701 committed Feb 3, 2020
1 parent 5fe4ac8 commit 87413d3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awscredx"
version = "0.8.0"
version = "0.8.1"
authors = ["Alexei Samokvalov <[email protected]>"]
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions src/assume/assumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::credentials::{CredentialsFile, ProfileName};

pub struct RoleAssumer<'a> {
region: Region,
store: CredentialsFile,
store: &'a mut CredentialsFile,
config: &'a Config,
}

Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/assume/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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(())
}

Expand Down
19 changes: 0 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down

0 comments on commit 87413d3

Please sign in to comment.