From 93c6f95eea94807391ab9dcabafa4f56e31ceda3 Mon Sep 17 00:00:00 2001 From: Matthew Yeazel Date: Tue, 6 Feb 2024 00:43:53 +0000 Subject: [PATCH] migrations: migrate to control container v0.7.8 --- Release.toml | 2 ++ sources/Cargo.lock | 14 ++++++++++ sources/Cargo.toml | 2 ++ .../aws-control-container-v0-7-8/Cargo.toml | 15 +++++++++++ .../aws-control-container-v0-7-8/src/main.rs | 27 +++++++++++++++++++ .../Cargo.toml | 15 +++++++++++ .../src/main.rs | 25 +++++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/src/main.rs create mode 100644 sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/src/main.rs diff --git a/Release.toml b/Release.toml index 615f7ab0143..d5f6de186b4 100644 --- a/Release.toml +++ b/Release.toml @@ -267,4 +267,6 @@ version = "1.19.1" "(1.19.0, 1.19.1)" = [ "migrate_v1.19.1_aws-admin-container-v0-11-4.lz4", "migrate_v1.19.1_public-admin-container-v0-11-4.lz4", + "migrate_v1.19.1_aws-control-container-v0-7-8.lz4", + "migrate_v1.19.1_public-control-container-v0-7-8.lz4", ] diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 4a143e0276c..af7a4af03ee 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -612,6 +612,13 @@ dependencies = [ "migration-helpers", ] +[[package]] +name = "aws-control-container-v0-7-8" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "aws-credential-types" version = "0.55.3" @@ -3162,6 +3169,13 @@ dependencies = [ "migration-helpers", ] +[[package]] +name = "public-control-container-v0-7-8" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "quick-xml" version = "0.26.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index a42bf592d66..e696d67a2c3 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -59,6 +59,8 @@ members = [ "api/migration/migrations/v1.19.0/add-additional-ecs-settings", "api/migration/migrations/v1.19.1/aws-admin-container-v0-11-4", "api/migration/migrations/v1.19.1/public-admin-container-v0-11-4", + "api/migration/migrations/v1.19.1/aws-control-container-v0-7-8", + "api/migration/migrations/v1.19.1/public-control-container-v0-7-8", "bloodhound", diff --git a/sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/Cargo.toml b/sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/Cargo.toml new file mode 100644 index 00000000000..da5be5f7cc6 --- /dev/null +++ b/sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "aws-control-container-v0-7-8" +version = "0.1.0" +authors = ["Matthew Yeazel "] +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 = { path = "../../../migration-helpers", version = "0.1.0"} diff --git a/sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/src/main.rs b/sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/src/main.rs new file mode 100644 index 00000000000..2d9108d3cae --- /dev/null +++ b/sources/api/migration/migrations/v1.19.1/aws-control-container-v0-7-8/src/main.rs @@ -0,0 +1,27 @@ +use migration_helpers::common_migrations::ReplaceSchnauzerMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +const OLD_CONTROL_CTR_CMDLINE: &str = + "schnauzer-v2 render --requires 'aws@v1(helpers=[ecr-prefix])' --template '{{ ecr-prefix settings.aws.region }}/bottlerocket-control:v0.7.7'"; +const NEW_CONTROL_CTR_CMDLINE: &str = + "schnauzer-v2 render --requires 'aws@v1(helpers=[ecr-prefix])' --template '{{ ecr-prefix settings.aws.region }}/bottlerocket-control:v0.7.8'"; + +/// We bumped the version of the default control container +fn run() -> Result<()> { + migrate(ReplaceSchnauzerMigration { + setting: "settings.host-containers.control.source", + old_schnauzer_cmdline: OLD_CONTROL_CTR_CMDLINE, + new_schnauzer_cmdline: NEW_CONTROL_CTR_CMDLINE, + }) +} + +// 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/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/Cargo.toml b/sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/Cargo.toml new file mode 100644 index 00000000000..191d544a05e --- /dev/null +++ b/sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "public-control-container-v0-7-8" +version = "0.1.0" +authors = ["Matthew Yeazel "] +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 = { path = "../../../migration-helpers", version = "0.1.0"} diff --git a/sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/src/main.rs b/sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/src/main.rs new file mode 100644 index 00000000000..769c5e31332 --- /dev/null +++ b/sources/api/migration/migrations/v1.19.1/public-control-container-v0-7-8/src/main.rs @@ -0,0 +1,25 @@ +use migration_helpers::common_migrations::ReplaceStringMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +const OLD_CONTROL_CTR_SOURCE_VAL: &str = "public.ecr.aws/bottlerocket/bottlerocket-control:v0.7.7"; +const NEW_CONTROL_CTR_SOURCE_VAL: &str = "public.ecr.aws/bottlerocket/bottlerocket-control:v0.7.8"; + +/// We bumped the version of the default control container +fn run() -> Result<()> { + migrate(ReplaceStringMigration { + setting: "settings.host-containers.control.source", + old_val: OLD_CONTROL_CTR_SOURCE_VAL, + new_val: NEW_CONTROL_CTR_SOURCE_VAL, + }) +} + +// 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); + } +}