From 0c163e1026733f9d1baa06d16601f39ee3bee023 Mon Sep 17 00:00:00 2001 From: Gavin Inglis Date: Fri, 25 Oct 2024 16:42:27 +0000 Subject: [PATCH] add migration for aws_config setting generator Add migration for the new aws_config setting generator. Signed-off-by: Gavin Inglis --- Release.toml | 5 ++++- sources/Cargo.lock | 7 +++++++ sources/Cargo.toml | 1 + .../aws-config-fips-endpoint/Cargo.toml | 15 +++++++++++++ .../aws-config-fips-endpoint/src/main.rs | 21 +++++++++++++++++++ sources/shared-defaults/aws-creds.toml | 3 +++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/Cargo.toml create mode 100644 sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/src/main.rs diff --git a/Release.toml b/Release.toml index 399281e04e5..c8350fb4603 100644 --- a/Release.toml +++ b/Release.toml @@ -1,4 +1,4 @@ -version = "1.26.1" +version = "1.27.0" [migrations] "(0.3.1, 0.3.2)" = ["migrate_v0.3.2_admin-container-v0-5-0.lz4"] @@ -367,3 +367,6 @@ version = "1.26.1" ] "(1.25.0, 1.26.0)" = [] "(1.26.0, 1.26.1)" = [] +"(1.26.1, 1.27.0)" = [ + "migrate_v1.27.0_aws-config.lz4", +] diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 603355c6a1a..e44f93d8097 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -313,6 +313,13 @@ dependencies = [ "migration-helpers", ] +[[package]] +name = "aws-config" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "aws-control-container-v0-7-14" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index acfa15b6512..ad5ac52dd60 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -65,6 +65,7 @@ members = [ "settings-migrations/v1.25.0/public-admin-container-v0-11-13", "settings-migrations/v1.25.0/aws-control-container-v0-7-17", "settings-migrations/v1.25.0/public-control-container-v0-7-17", + "settings-migrations/v1.27.0/aws-config", "settings-plugins/aws-dev", "settings-plugins/aws-ecs-1", "settings-plugins/aws-ecs-2", diff --git a/sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/Cargo.toml b/sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/Cargo.toml new file mode 100644 index 00000000000..d6332786c39 --- /dev/null +++ b/sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "aws-config" +version = "0.1.0" +authors = ["Gavin Inglis "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false +# Don't rebuild crate just because of changes to README. +exclude = ["README.md"] + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +migration-helpers.workspace = true diff --git a/sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/src/main.rs b/sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/src/main.rs new file mode 100644 index 00000000000..83b6418aeae --- /dev/null +++ b/sources/settings-migrations/v1.27.0/aws-config-fips-endpoint/src/main.rs @@ -0,0 +1,21 @@ +use migration_helpers::common_migrations::{AddMetadataMigration, SettingMetadata}; +use migration_helpers::{migrate, Result}; +use std::process; + +/// We added new settings metadata, `aws.config.setting-generator` +fn run() -> Result<()> { + migrate(AddMetadataMigration(&[SettingMetadata { + metadata: &["setting-generator"], + setting: "settings.aws.config", + }])) +} + +// Returning a Result from main makes it print a Debug representation of the error, but with Snafu +// we have nice Display representations of the error, so we wrap "main" (run) and print any error. +// https://github.com/shepmaster/snafu/issues/110 +fn main() { + if let Err(e) = run() { + eprintln!("{}", e); + process::exit(1); + } +} diff --git a/sources/shared-defaults/aws-creds.toml b/sources/shared-defaults/aws-creds.toml index d1f1c6ab739..06eeb08b9d5 100644 --- a/sources/shared-defaults/aws-creds.toml +++ b/sources/shared-defaults/aws-creds.toml @@ -1,6 +1,9 @@ [settings.aws] profile = "default" +[metadata.settings.aws.config] +setting-generator = "schnauzer-v2 render --requires 'aws@v1(helpers=[aws_config])' --template '{{ aws_config settings.aws.config settings.aws.profile }}'" + [services.aws] configuration-files = [ "aws-config",