Skip to content

Commit

Permalink
pubsys: default AwsConfig so it's not required
Browse files Browse the repository at this point in the history
Have serde default `aws.region` so the user does not have to have an empty
`aws.region` table if they have no region-specific configuration.

Have serde default `aws.regions` in case the user only wants to specify regions
on the command line with `PUBLISH_REGIONS`.

Derive Default on AwsConfig now that all sections of `aws` in Infra.toml are
optional, so the user doesn't need an empty `[aws]` section if they intend to
use default credential mechanisms and specify `PUBLISH_REGIONS`.

Co-authored-by: Zac Mrowicki <mrowicki@amazon.com>
Co-authored-by: Tom Kirchner <tjk@amazon.com>
  • Loading branch information
zmrow and tjkirch committed Aug 11, 2020
1 parent 4d549bf commit 4c22b4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions tools/pubsys/src/aws/ami/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ pub(crate) async fn run(args: &Args, ami_args: &AmiArgs) -> Result<()> {
let infra_config = InfraConfig::from_path(&args.infra_config_path).context(error::Config)?;
trace!("Parsed infra config: {:?}", infra_config);

let aws = infra_config.aws.context(error::MissingConfig {
missing: "aws section",
})?;
let aws = infra_config.aws.unwrap_or_else(|| Default::default());

// If the user gave an override list of regions, use that, otherwise use what's in the config.
let mut regions = if !ami_args.regions.is_empty() {
Expand Down
4 changes: 3 additions & 1 deletion tools/pubsys/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ impl InfraConfig {
}

/// AWS-specific infrastructure configuration
#[derive(Debug, Deserialize)]
#[derive(Debug, Default, Deserialize)]
pub(crate) struct AwsConfig {
#[serde(default)]
pub(crate) regions: VecDeque<String>,
pub(crate) role: Option<String>,
pub(crate) profile: Option<String>,
#[serde(default)]
pub(crate) region: HashMap<String, AwsRegionConfig>,
}

Expand Down

0 comments on commit 4c22b4d

Please sign in to comment.