Skip to content

Commit

Permalink
migrations: Add migrations for settings.dns
Browse files Browse the repository at this point in the history
This adds the migrations needed for `settings.dns`, one for the setting,
its service and configuration file, and one for the setting metadata.
  • Loading branch information
zmrow committed Sep 1, 2022
1 parent 6926322 commit 228d981
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,7 @@ version = "1.9.2"
]
"(1.9.0, 1.9.1)" = []
"(1.9.1, 1.9.2)" = []
"(1.9.2, 1.10.0)" = [
"migrate_v1.10.0_dns-settings.lz4",
"migrate_v1.10.0_dns-settings-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.

3 changes: 2 additions & 1 deletion sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ members = [
"api/prairiedog",

# "api/migration/migrations/vX.Y.Z/..."
# (all migrations currently archived; replace this line with new ones)
"api/migration/migrations/v1.10.0/dns-settings",
"api/migration/migrations/v1.10.0/dns-settings-metadata",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "dns-settings-metadata"
version = "0.1.0"
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"}
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 `affected-services` metadata for `settings.dns`
fn run() -> Result<()> {
migrate(AddMetadataMigration(&[SettingMetadata {
metadata: &["affected-services"],
setting: "settings.dns",
}]))
}

// 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,9 @@
[package]
name = "dns-settings"
version = "0.1.0"
license = "Apache-2.0 OR MIT"
edition = "2018"
publish = false

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"}
24 changes: 24 additions & 0 deletions sources/api/migration/migrations/v1.10.0/dns-settings/src/main.rs
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 new settings under `settings.dns` for configuring /etc/resolv.conf
fn run() -> Result<()> {
migrate(AddPrefixesMigration(vec![
"settings.dns",
"services.dns",
"configuration-files.netdog-toml",
]))
}

// 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 228d981

Please sign in to comment.