Skip to content

Commit

Permalink
Add migrations for settings.network.hostname
Browse files Browse the repository at this point in the history
This adds the migrations needed for `settings.network.hostname`, one for
the setting, its service and configuration file, and one for the setting
generator metadata.
  • Loading branch information
zmrow committed Jul 29, 2021
1 parent 5fe7fa5 commit 9719b40
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ version = "1.1.4"
"migrate_v1.1.3_kubelet-cpu-manager.lz4",
]
"(1.1.3, 1.1.4)" = []
"(1.1.4, 1.1.5)" = [
"migrate_v1.1.5_hostname-setting.lz4",
"migrate_v1.1.5_hostname-setting-metadata.lz4",
]
14 changes: 14 additions & 0 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ members = [
"api/migration/migrations/v1.1.2/control-container-v0-5-1",
"api/migration/migrations/v1.1.3/kubelet-cpu-manager-state",
"api/migration/migrations/v1.1.3/kubelet-cpu-manager",
"api/migration/migrations/v1.1.5/hostname-setting",
"api/migration/migrations/v1.1.5/hostname-setting-metadata",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "hostname-setting-metadata"
version = "0.1.0"
authors = ["Zac Mrowicki <mrowicki@amazon.com>"]
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" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![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 generator for configuring hostname
fn run() -> Result<()> {
migrate(AddMetadataMigration(&[SettingMetadata {
metadata: &["setting-generator", "affected-services"],
setting: "settings.network.hostname",
}]))
}

// 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "hostname-setting"
version = "0.1.0"
authors = ["Zac Mrowicki <mrowicki@amazon.com>"]
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" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![deny(rust_2018_idioms)]

use migration_helpers::common_migrations::AddPrefixesMigration;
use migration_helpers::{migrate, Result};
use std::process;

/// We added a new setting and generator for configuring hostname
fn run() -> Result<()> {
migrate(AddPrefixesMigration(vec![
"settings.network.hostname",
"services.hostname",
"configuration-files.hostname",
]))
}

// 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);
}
}

0 comments on commit 9719b40

Please sign in to comment.