-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrations: add migrations for 'settings.oci-defaults'
Co-authored-by: Mahdi Chaker <mmchaker@amazon.com> Co-authored-by: Matthew James Briggs <brigmatt@amazon.com>
- Loading branch information
Showing
9 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
sources/api/migration/migrations/v1.12.0/oci-defaults-setting-metadata/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "oci-defaults-setting-metadata" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["Mahdi Chaker <mmchaker@amazon.com>"] | ||
license = "Apache-2.0 OR MIT" | ||
publish = false | ||
# Don't rebuild crate just because of changes to README. | ||
exclude = ["README.md"] | ||
|
||
[dependencies] | ||
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} | ||
|
||
[build-dependencies] | ||
bottlerocket-variant = { version = "0.1", path = "../../../../../bottlerocket-variant" } |
6 changes: 6 additions & 0 deletions
6
sources/api/migration/migrations/v1.12.0/oci-defaults-setting-metadata/build.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use bottlerocket_variant::Variant; | ||
|
||
fn main() { | ||
let variant = Variant::from_env().unwrap(); | ||
variant.emit_cfgs(); | ||
} |
28 changes: 28 additions & 0 deletions
28
sources/api/migration/migrations/v1.12.0/oci-defaults-setting-metadata/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![deny(rust_2018_idioms)] | ||
use migration_helpers::common_migrations::{AddMetadataMigration, SettingMetadata}; | ||
use migration_helpers::{migrate, Result}; | ||
use std::process; | ||
|
||
/// We updated the 'affected-services' list metadata for 'settings.oci-defaults' | ||
/// to include itself and containerd on upgrade, and to remove those values on | ||
/// downgrade, depending on the running variant. | ||
fn run() -> Result<()> { | ||
if cfg!(variant_runtime = "k8s") { | ||
migrate(AddMetadataMigration(&[SettingMetadata { | ||
metadata: &["affected-services"], | ||
setting: "settings.oci-defaults", | ||
}]))? | ||
}; | ||
|
||
Ok(()) | ||
} | ||
|
||
// 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); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
sources/api/migration/migrations/v1.12.0/oci-defaults-setting/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "oci-defaults-setting" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["Mahdi Chaker <mmchaker@amazon.com>"] | ||
license = "Apache-2.0 OR MIT" | ||
publish = false | ||
# Don't rebuild crate just because of changes to README. | ||
exclude = ["README.md"] | ||
|
||
[dependencies] | ||
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0"} | ||
|
||
[build-dependencies] | ||
bottlerocket-variant = { version = "0.1", path = "../../../../../bottlerocket-variant" } |
6 changes: 6 additions & 0 deletions
6
sources/api/migration/migrations/v1.12.0/oci-defaults-setting/build.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use bottlerocket_variant::Variant; | ||
|
||
fn main() { | ||
let variant = Variant::from_env().unwrap(); | ||
variant.emit_cfgs(); | ||
} |
31 changes: 31 additions & 0 deletions
31
sources/api/migration/migrations/v1.12.0/oci-defaults-setting/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#![deny(rust_2018_idioms)] | ||
|
||
use migration_helpers::common_migrations; | ||
use migration_helpers::{migrate, Result}; | ||
use std::process; | ||
|
||
/// We added new settings for configuring the default OCI runtime spec, | ||
/// `settings.oci-defaults`, which will initially contain | ||
/// `settings.oci-defaults.capabilities` and | ||
/// `settings.oci-defaults.resource-limits` | ||
fn run() -> Result<()> { | ||
if cfg!(variant_runtime = "k8s") { | ||
migrate(common_migrations::AddPrefixesMigration(vec![ | ||
"settings.oci-defaults", | ||
"services.oci-defaults", | ||
"configuration-files.oci-defaults", | ||
]))? | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
// 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); | ||
} | ||
} |