From a5bcf5625c14a8d074e43f1dd519612c0a86a0fb Mon Sep 17 00:00:00 2001 From: Shikha Vyaghra Date: Fri, 6 Dec 2024 00:44:03 +0000 Subject: [PATCH] migrations: Change public admin host-container source metadata to object This migration will change the public admin host-container source to setting-generator metadata(that will generate source using sundog) on forward migration. In backward migration, it will reset the value of the source as string. --- Release.toml | 2 -- .../Cargo.toml | 15 +++++++++++ .../src/main.rs | 27 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/Cargo.toml create mode 100644 sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/src/main.rs diff --git a/Release.toml b/Release.toml index 099c26bf3db..06bfeff0539 100644 --- a/Release.toml +++ b/Release.toml @@ -379,11 +379,9 @@ version = "1.28.0" "migrate_v1.28.0_aws-control-container-v0-7-18.lz4", "migrate_v1.28.0_public-control-container-v0-7-18.lz4", ] -"(1.28.0, 1.29.0)" = [ "migrate_v1.29.0_remove_weak_settings_migration.lz4", "migrate_v1.29.0_update-settings-generator-admin.lz4", "migrate_v1.29.0_update-settings-generator-control.lz4", "migrate_v1.29.0_change-public-admin-container-to-set-gen.lz4", "migrate_v1.29.0_change-public-control-container-to-set-gen.lz4", -] diff --git a/sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/Cargo.toml b/sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/Cargo.toml new file mode 100644 index 00000000000..de0a02f71a3 --- /dev/null +++ b/sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "change-public-admin-container-to-set-gen" +version = "0.1.0" +authors = ["Shikha Vyaghra "] +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.29.0/change-public-admin-container-to-set-gen/src/main.rs b/sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/src/main.rs new file mode 100644 index 00000000000..32768ad7ec1 --- /dev/null +++ b/sources/settings-migrations/v1.29.0/change-public-admin-container-to-set-gen/src/main.rs @@ -0,0 +1,27 @@ +use migration_helpers::common_migrations::ReplaceSettingWithSettingGeneratorMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +const OLD_ADMIN_CTR: &str = "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.14"; +const NEW_ADMIN_CTR: &str = "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.14"; + +/// We bumped the version of the default admin container +fn run() -> Result<()> { + migrate(ReplaceSettingWithSettingGeneratorMigration { + setting: "settings.host-containers.admin.source", + old_val: OLD_ADMIN_CTR, + new_val: NEW_ADMIN_CTR, + setting_gen_command: "emitter public.ecr.aws/bottlerocket/bottlerocket-admin:v0.11.13", + skip_if_populated: true, + }) +} + +// 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); + } +}