diff --git a/sources/Cargo.lock b/sources/Cargo.lock index e270462164b..7f1d02141ce 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -1386,6 +1386,13 @@ name = "memchr" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "migrate-admin-container-v0_5_0" +version = "0.1.0" +dependencies = [ + "migration-helpers 0.1.0", +] + [[package]] name = "migration-helpers" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index ea8853cd9bb..36733745351 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -17,6 +17,7 @@ members = [ "api/migration/migration-helpers", # "api/migration/migrations/vX.Y.Z/... + "api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0", "bottlerocket-release", diff --git a/sources/api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0/Cargo.toml b/sources/api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0/Cargo.toml new file mode 100644 index 00000000000..7ced78593d7 --- /dev/null +++ b/sources/api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "migrate-admin-container-v0_5_0" +version = "0.1.0" +authors = ["Erikson Tung "] +license = "Apache-2.0 OR MIT" +edition = "2018" +publish = false + +[dependencies] +migration-helpers = { path = "../../../migration-helpers" } diff --git a/sources/api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0/src/main.rs b/sources/api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0/src/main.rs new file mode 100644 index 00000000000..a42a0516ff6 --- /dev/null +++ b/sources/api/migration/migrations/v0.3.2/migrate-admin-container-v0_5_0/src/main.rs @@ -0,0 +1,29 @@ +#![deny(rust_2018_idioms)] + +use migration_helpers::common_migrations::ReplaceTemplateMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +const OLD_ADMIN_CTR_TEMPLATE: &str = + "328549459982.dkr.ecr.{{ settings.aws.region }}.amazonaws.com/bottlerocket-admin:v0.4.0"; +const NEW_ADMIN_CTR_TEMPLATE: &str = + "328549459982.dkr.ecr.{{ settings.aws.region }}.amazonaws.com/bottlerocket-admin:v0.5.0"; + +/// We bumped the version of the default admin container from v0.4.0 to v0.5.0 +fn run() -> Result<()> { + migrate(ReplaceTemplateMigration { + setting: "settings.host-containers.admin.source", + old_template: OLD_ADMIN_CTR_TEMPLATE, + new_template: NEW_ADMIN_CTR_TEMPLATE, + }) +} + +// 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/models/defaults.toml b/sources/models/defaults.toml index 4080ca6b6ee..6286a664686 100644 --- a/sources/models/defaults.toml +++ b/sources/models/defaults.toml @@ -58,7 +58,7 @@ superpowered = true [metadata.settings.host-containers.admin.source] setting-generator = "schnauzer settings.host-containers.admin.source" -template = "328549459982.dkr.ecr.{{ settings.aws.region }}.amazonaws.com/bottlerocket-admin:v0.4.0" +template = "328549459982.dkr.ecr.{{ settings.aws.region }}.amazonaws.com/bottlerocket-admin:v0.5.0" [settings.host-containers.control] enabled = true