From 10763975aa9e4333d1b06c7acc95b924efbf3676 Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Wed, 14 Feb 2024 02:13:33 +0000 Subject: [PATCH] migrations: migrate host-containers to use config file Signed-off-by: Sam Berning --- Release.toml | 2 ++ sources/Cargo.lock | 14 ++++++++++++++ sources/Cargo.toml | 2 ++ .../Cargo.toml | 11 +++++++++++ .../src/main.rs | 17 +++++++++++++++++ .../Cargo.toml | 11 +++++++++++ .../src/main.rs | 19 +++++++++++++++++++ 7 files changed, 76 insertions(+) create mode 100644 sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/src/main.rs create mode 100644 sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/Cargo.toml create mode 100644 sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/src/main.rs diff --git a/Release.toml b/Release.toml index 6a0e6fa93e3..c994e5494aa 100644 --- a/Release.toml +++ b/Release.toml @@ -273,4 +273,6 @@ version = "1.19.2" "(1.19.1, 1.19.2)" = [ "migrate_v1.19.2_certdog-config-file-v0-1-0.lz4", "migrate_v1.19.2_certdog-service-cfg-v0-1-0.lz4", + "migrate_v1.19.2_host-containers-config-file-v0-1-0.lz4", + "migrate_v1.19.2_host-containers-config-list-v0-1-0.lz4", ] diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 32b96198602..d4a2b9a9b90 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2113,6 +2113,20 @@ dependencies = [ "toml 0.8.8", ] +[[package]] +name = "host-containers-config-file-v0-1-0" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + +[[package]] +name = "host-containers-config-list-v0-1-0" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "http" version = "0.2.11" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index cda13db3699..99a6e9cd89f 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -63,6 +63,8 @@ members = [ "api/migration/migrations/v1.19.1/public-control-container-v0-7-8", "api/migration/migrations/v1.19.2/certdog-config-file-v0-1-0", "api/migration/migrations/v1.19.2/certdog-service-cfg-v0-1-0", + "api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0", + "api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0", "bloodhound", diff --git a/sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/Cargo.toml b/sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/Cargo.toml new file mode 100644 index 00000000000..d38e35dc896 --- /dev/null +++ b/sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "host-containers-config-file-v0-1-0" +version = "0.1.0" +authors = ["Sam Berning "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false +exclude = ["README.md"] + +[dependencies] +migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" } diff --git a/sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/src/main.rs b/sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/src/main.rs new file mode 100644 index 00000000000..9ccf035d737 --- /dev/null +++ b/sources/api/migration/migrations/v1.19.2/host-containers-config-file-v0-1-0/src/main.rs @@ -0,0 +1,17 @@ +use migration_helpers::common_migrations::AddPrefixesMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +// Create the new config file +fn run() -> Result<()> { + migrate(AddPrefixesMigration(vec![ + "configuration-files.host-containers-toml", + ])) +} + +fn main() { + if let Err(e) = run() { + eprintln!("{}", e); + process::exit(1); + } +} diff --git a/sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/Cargo.toml b/sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/Cargo.toml new file mode 100644 index 00000000000..21a9d08a6f0 --- /dev/null +++ b/sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "host-containers-config-list-v0-1-0" +version = "0.1.0" +authors = ["Sam Berning "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false +exclude = ["README.md"] + +[dependencies] +migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" } diff --git a/sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/src/main.rs b/sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/src/main.rs new file mode 100644 index 00000000000..13423870bed --- /dev/null +++ b/sources/api/migration/migrations/v1.19.2/host-containers-config-list-v0-1-0/src/main.rs @@ -0,0 +1,19 @@ +use migration_helpers::common_migrations::{ListReplacement, ReplaceListsMigration}; +use migration_helpers::{migrate, Result}; +use std::process; + +// Add new config file to host-containers +fn run() -> Result<()> { + migrate(ReplaceListsMigration(vec![ListReplacement { + setting: "service.host-containers.configuration-files", + old_vals: &["host-ctr-toml"], + new_vals: &["host-ctr-toml", "host-containers-toml"], + }])) +} + +fn main() { + if let Err(e) = run() { + eprintln!("{}", e); + process::exit(1); + } +}