Skip to content

Commit

Permalink
migrations: add migrations for 'settings.container-registry.credentials'
Browse files Browse the repository at this point in the history
  • Loading branch information
etungsten committed Mar 5, 2022
1 parent 20a7ddd commit 6f59a59
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
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 @@ -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",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "container-registry-credentials-metadata"
version = "0.1.0"
authors = ["Erikson Tung <etung@amazon.com>"]
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,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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "container-registry-credentials"
version = "0.1.0"
authors = ["Erikson Tung <etung@amazon.com>"]
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,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);
}
}

0 comments on commit 6f59a59

Please sign in to comment.