From 6f59a594ca258bea2d68c4c19ee6e9e065cf2cd2 Mon Sep 17 00:00:00 2001 From: Erikson Tung Date: Mon, 28 Feb 2022 18:40:20 -0800 Subject: [PATCH] migrations: add migrations for 'settings.container-registry.credentials' --- Release.toml | 2 ++ sources/Cargo.lock | 14 +++++++++ sources/Cargo.toml | 2 ++ .../Cargo.toml | 10 ++++++ .../src/main.rs | 31 +++++++++++++++++++ .../container-registry-credentials/Cargo.toml | 10 ++++++ .../src/main.rs | 22 +++++++++++++ 7 files changed, 91 insertions(+) create mode 100644 sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/src/main.rs create mode 100644 sources/api/migration/migrations/v1.6.2/container-registry-credentials/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.6.2/container-registry-credentials/src/main.rs diff --git a/Release.toml b/Release.toml index f69c590bb66..13fe2ced7f0 100644 --- a/Release.toml +++ b/Release.toml @@ -103,4 +103,6 @@ version = "1.6.1" "(1.6.0, 1.6.1)" = [] "(1.6.1, 1.6.2)" = [ "migrate_v1.6.2_add-cfsignal.lz4", + "migrate_v1.6.2_container-registry-credentials.lz4", + "migrate_v1.6.2_container-registry-credentials-metadata.lz4", ] diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 4dbfa34c81b..d0a6014186f 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -708,6 +708,20 @@ dependencies = [ "cargo-readme", ] +[[package]] +name = "container-registry-credentials" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + +[[package]] +name = "container-registry-credentials-metadata" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "control-container-v0-5-2" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index 00ca69bda57..f1e83b25788 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -41,6 +41,8 @@ members = [ "api/migration/migrations/v1.6.0/public-admin-container-v0-7-4", "api/migration/migrations/v1.6.0/public-control-container-v0-5-5", "api/migration/migrations/v1.6.2/add-cfsignal", + "api/migration/migrations/v1.6.2/container-registry-credentials", + "api/migration/migrations/v1.6.2/container-registry-credentials-metadata", "bottlerocket-release", diff --git a/sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/Cargo.toml b/sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/Cargo.toml new file mode 100644 index 00000000000..fd549e10c55 --- /dev/null +++ b/sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "container-registry-credentials-metadata" +version = "0.1.0" +authors = ["Erikson Tung "] +license = "Apache-2.0 OR MIT" +edition = "2018" +publish = false + +[dependencies] +migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} diff --git a/sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/src/main.rs b/sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/src/main.rs new file mode 100644 index 00000000000..312d435f24a --- /dev/null +++ b/sources/api/migration/migrations/v1.6.2/container-registry-credentials-metadata/src/main.rs @@ -0,0 +1,31 @@ +#![deny(rust_2018_idioms)] + +use migration_helpers::common_migrations::{AddMetadataMigration, SettingMetadata}; +use migration_helpers::{migrate, Result}; +use std::process; + +/// We added a new setting and `affected-services` metadata for `container-registry.credentials` +/// We subdivided metadata for `container-registry` into `container-registry.mirrors` and `container-registry.credentials` +/// This is for the docker variants where don't want to restart the docker daemon when credentials settings change. +fn run() -> Result<()> { + migrate(AddMetadataMigration(&[ + SettingMetadata { + metadata: &["affected-services"], + setting: "settings.container-registry.credentials", + }, + SettingMetadata { + metadata: &["affected-services"], + setting: "settings.container-registry.mirrors", + }, + ])) +} + +// 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.6.2/container-registry-credentials/Cargo.toml b/sources/api/migration/migrations/v1.6.2/container-registry-credentials/Cargo.toml new file mode 100644 index 00000000000..a3b01c55bf6 --- /dev/null +++ b/sources/api/migration/migrations/v1.6.2/container-registry-credentials/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "container-registry-credentials" +version = "0.1.0" +authors = ["Erikson Tung "] +license = "Apache-2.0 OR MIT" +edition = "2018" +publish = false + +[dependencies] +migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} diff --git a/sources/api/migration/migrations/v1.6.2/container-registry-credentials/src/main.rs b/sources/api/migration/migrations/v1.6.2/container-registry-credentials/src/main.rs new file mode 100644 index 00000000000..b8fb5033867 --- /dev/null +++ b/sources/api/migration/migrations/v1.6.2/container-registry-credentials/src/main.rs @@ -0,0 +1,22 @@ +#![deny(rust_2018_idioms)] + +use migration_helpers::common_migrations::AddPrefixesMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +/// We added a new setting for configuring image credentials, `settings.container-registry.credentials` +fn run() -> Result<()> { + migrate(AddPrefixesMigration(vec![ + "settings.container-registry.credentials", + ])) +} + +// 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); + } +}