From f1f7015e27f49677f9a1f904734dc7cdd1cf7e07 Mon Sep 17 00:00:00 2001 From: Erikson Tung Date: Thu, 13 Aug 2020 09:32:04 -0700 Subject: [PATCH] migrations: add `cluster-domain` setting Add a migration for migrating the new `cluster-domain` setting --- sources/Cargo.lock | 7 ++++++ sources/Cargo.toml | 1 + .../v0.5.0/add-cluster-domain/Cargo.toml | 12 ++++++++++ .../v0.5.0/add-cluster-domain/src/main.rs | 22 +++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 sources/api/migration/migrations/v0.5.0/add-cluster-domain/Cargo.toml create mode 100644 sources/api/migration/migrations/v0.5.0/add-cluster-domain/src/main.rs diff --git a/sources/Cargo.lock b/sources/Cargo.lock index be41e62d5a3..e19d2c06c86 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -242,6 +242,13 @@ dependencies = [ "syn 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "add-cluster-domain" +version = "0.1.0" +dependencies = [ + "migration-helpers 0.1.0", +] + [[package]] name = "add-version-lock-ignore-waves" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index 6706b2cef42..6f13096f7c5 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -24,6 +24,7 @@ members = [ "api/migration/migrations/v0.4.1/pivot-repo-2020-07-07", "api/migration/migrations/v0.5.0/migrate-admin-container-v0-5-1", "api/migration/migrations/v0.5.0/migrate-control-container-v0-4-1", + "api/migration/migrations/v0.5.0/add-cluster-domain", "bottlerocket-release", diff --git a/sources/api/migration/migrations/v0.5.0/add-cluster-domain/Cargo.toml b/sources/api/migration/migrations/v0.5.0/add-cluster-domain/Cargo.toml new file mode 100644 index 00000000000..33134969c04 --- /dev/null +++ b/sources/api/migration/migrations/v0.5.0/add-cluster-domain/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "add-cluster-domain" +version = "0.1.0" +authors = ["Erikson Tung "] +license = "Apache-2.0 OR MIT" +edition = "2018" +publish = false +# Don't rebuild crate just because of changes to README. +exclude = ["README.md"] + +[dependencies] +migration-helpers = { path = "../../../migration-helpers" } diff --git a/sources/api/migration/migrations/v0.5.0/add-cluster-domain/src/main.rs b/sources/api/migration/migrations/v0.5.0/add-cluster-domain/src/main.rs new file mode 100644 index 00000000000..0f8f6c689e4 --- /dev/null +++ b/sources/api/migration/migrations/v0.5.0/add-cluster-domain/src/main.rs @@ -0,0 +1,22 @@ +#![deny(rust_2018_idioms)] + +use migration_helpers::common_migrations::AddSettingsMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +/// We added a new setting, `kubernetes.cluster-domain` +fn run() -> Result<()> { + migrate(AddSettingsMigration(&[ + "settings.kubernetes.cluster-domain", + ])) +} + +// 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); + } +}