From 4f79ca95adbf0d4589f6cfa7a0291f522d52dd6b Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Wed, 6 Dec 2023 14:41:54 -0800 Subject: [PATCH 1/3] settings: add container-registry settings extension Signed-off-by: Sam Berning --- sources/Cargo.lock | 18 ++- sources/Cargo.toml | 1 + .../container-registry/Cargo.toml | 19 +++ .../container-registry.toml | 13 ++ .../container-registry/src/de.rs | 47 +++++++ .../container-registry/src/lib.rs | 129 ++++++++++++++++++ .../container-registry/src/main.rs | 18 +++ sources/settings-extensions/motd/Cargo.toml | 2 +- sources/settings-extensions/ntp/Cargo.toml | 2 +- 9 files changed, 244 insertions(+), 5 deletions(-) create mode 100644 sources/settings-extensions/container-registry/Cargo.toml create mode 100644 sources/settings-extensions/container-registry/container-registry.toml create mode 100644 sources/settings-extensions/container-registry/src/de.rs create mode 100644 sources/settings-extensions/container-registry/src/lib.rs create mode 100644 sources/settings-extensions/container-registry/src/main.rs diff --git a/sources/Cargo.lock b/sources/Cargo.lock index ce9d445e232..db6fc771a54 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -1048,8 +1048,8 @@ dependencies = [ [[package]] name = "bottlerocket-settings-sdk" -version = "0.1.0-alpha.1" -source = "git+https://github.com/bottlerocket-os/bottlerocket-settings-sdk?tag=bottlerocket-settings-sdk-v0.1.0-alpha.1#6a7e2915f1ac3f70e839b8394256bc59f86f626e" +version = "0.1.0-alpha.2" +source = "git+https://github.com/bottlerocket-os/bottlerocket-settings-sdk?tag=bottlerocket-settings-sdk-v0.1.0-alpha.2#7a138e9de9d99944fbedc6a35c4d08607e459b24" dependencies = [ "argh", "bottlerocket-template-helper", @@ -1062,7 +1062,7 @@ dependencies = [ [[package]] name = "bottlerocket-template-helper" version = "0.1.0-alpha.0" -source = "git+https://github.com/bottlerocket-os/bottlerocket-settings-sdk?tag=bottlerocket-settings-sdk-v0.1.0-alpha.1#6a7e2915f1ac3f70e839b8394256bc59f86f626e" +source = "git+https://github.com/bottlerocket-os/bottlerocket-settings-sdk?tag=bottlerocket-settings-sdk-v0.1.0-alpha.2#7a138e9de9d99944fbedc6a35c4d08607e459b24" dependencies = [ "darling 0.20.3", "proc-macro2", @@ -3575,6 +3575,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "settings-extension-registry" +version = "0.1.0" +dependencies = [ + "bottlerocket-settings-sdk", + "env_logger", + "model-derive", + "modeled-types", + "serde", + "serde_json", +] + [[package]] name = "sha1" version = "0.10.6" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index 92026887fe3..61492b40885 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -73,6 +73,7 @@ members = [ "settings-extensions/motd", "settings-extensions/ntp", + "settings-extensions/container-registry", "parse-datetime", diff --git a/sources/settings-extensions/container-registry/Cargo.toml b/sources/settings-extensions/container-registry/Cargo.toml new file mode 100644 index 00000000000..e5182c2fbf4 --- /dev/null +++ b/sources/settings-extensions/container-registry/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "settings-extension-container-registry" +version = "0.1.0" +authors = ["Sam Berning "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false + +[dependencies] +env_logger = "0.10" +modeled-types = { path = "../../models/modeled-types", version = "0.1" } +model-derive = { path = "../../models/model-derive", version = "0.1" } +serde = { version = "1", features = ["derive"] } +serde_json = "1" + +[dependencies.bottlerocket-settings-sdk] +git = "https://github.com/bottlerocket-os/bottlerocket-settings-sdk" +tag = "bottlerocket-settings-sdk-v0.1.0-alpha.2" +version = "0.1.0-alpha" diff --git a/sources/settings-extensions/container-registry/container-registry.toml b/sources/settings-extensions/container-registry/container-registry.toml new file mode 100644 index 00000000000..727dfb274cd --- /dev/null +++ b/sources/settings-extensions/container-registry/container-registry.toml @@ -0,0 +1,13 @@ +[extension] +supported-versions = [ + "v1" +] +default-version = "v1" + +[v1] +[v1.validation.cross-validates] + +[v1.templating] +helpers = [] + +[v1.generation.requires] diff --git a/sources/settings-extensions/container-registry/src/de.rs b/sources/settings-extensions/container-registry/src/de.rs new file mode 100644 index 00000000000..8be4dd3ed18 --- /dev/null +++ b/sources/settings-extensions/container-registry/src/de.rs @@ -0,0 +1,47 @@ +use crate::RegistryMirrorV1; +use serde::de::value::SeqAccessDeserializer; +use serde::de::{MapAccess, SeqAccess, Visitor}; +use serde::{Deserialize, Deserializer}; +use std::fmt::Formatter; + +// Our standard representation of registry mirrors is a `Vec` of `RegistryMirror`; for backward compatibility, we also allow a `HashMap` of registry to endpoints. +pub(crate) fn deserialize_mirrors<'de, D>( + deserializer: D, +) -> Result>, D::Error> +where + D: Deserializer<'de>, +{ + struct TableOrArray; + + impl<'de> Visitor<'de> for TableOrArray { + type Value = Option>; + + fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result { + formatter.write_str("TOML array or TOML table") + } + + fn visit_seq(self, seq: A) -> Result + where + A: SeqAccess<'de>, + { + Ok(Some(Deserialize::deserialize(SeqAccessDeserializer::new( + seq, + ))?)) + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'de>, + { + let mut vec = Vec::new(); + while let Some((k, v)) = map.next_entry()? { + vec.push(RegistryMirrorV1 { + registry: Some(k), + endpoint: Some(v), + }); + } + Ok(Some(vec)) + } + } + deserializer.deserialize_any(TableOrArray) +} diff --git a/sources/settings-extensions/container-registry/src/lib.rs b/sources/settings-extensions/container-registry/src/lib.rs new file mode 100644 index 00000000000..5d648312752 --- /dev/null +++ b/sources/settings-extensions/container-registry/src/lib.rs @@ -0,0 +1,129 @@ +/// The container-registry settings can be used to configure settings related to container +/// registries, including credentials for logging into a registry, or mirrors to use when +/// pulling from a registry. +mod de; + +use crate::de::deserialize_mirrors; +use bottlerocket_settings_sdk::{GenerateResult, SettingsModel}; +use model_derive::model; +use modeled_types::{SingleLineString, Url, ValidBase64}; +use std::convert::Infallible; + +#[model(impl_default = true)] +struct RegistryMirrorV1 { + registry: SingleLineString, + endpoint: Vec, +} + +#[model(impl_default = true)] +struct RegistryCredentialV1 { + registry: SingleLineString, + username: SingleLineString, + password: SingleLineString, + // This is the base64 encoding of "username:password" + auth: ValidBase64, + identitytoken: SingleLineString, +} + +#[model(impl_default = true)] +struct RegistrySettingsV1 { + #[serde( + default, + skip_serializing_if = "Option::is_none", + deserialize_with = "deserialize_mirrors" + )] + mirrors: Vec, + #[serde(alias = "creds", default, skip_serializing_if = "Option::is_none")] + credentials: Vec, +} + +type Result = std::result::Result; + +impl SettingsModel for RegistrySettingsV1 { + type PartialKind = Self; + type ErrorKind = Infallible; + + fn get_version() -> &'static str { + "v1" + } + + fn set( + _current_value: Option, + _target: Self, + ) -> std::result::Result<(), Self::ErrorKind> { + // Anything that correctly deserializes to RegistrySettingsV1 is ok + Ok(()) + } + + fn generate( + existing_partial: Option, + _dependent_settings: Option, + ) -> Result> { + Ok(GenerateResult::Complete( + existing_partial.unwrap_or_default(), + )) + } + + fn validate( + _value: Self, + _validated_settings: Option, + ) -> std::result::Result<(), Self::ErrorKind> { + Ok(()) + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_generate_container_registry_settings() { + assert_eq!( + RegistrySettingsV1::generate(None, None), + Ok(GenerateResult::Complete(RegistrySettingsV1 { + mirrors: None, + credentials: None, + })) + ) + } + + #[test] + fn test_serde_container_registry_with_mirrors() { + let test_json = + r#"{"mirrors": [{"registry": "foo", "endpoint": ["https://example.net"]}]}"#; + + let container_registry: RegistrySettingsV1 = serde_json::from_str(test_json).unwrap(); + let mirrors = container_registry.mirrors.unwrap(); + + assert_eq!(mirrors.len(), 1); + assert_eq!( + mirrors[0].registry.clone().unwrap(), + SingleLineString::try_from("foo").unwrap(), + ); + assert_eq!( + mirrors[0].endpoint.clone().unwrap(), + vec!(Url::try_from("https://example.net").unwrap()), + ); + } + + #[test] + fn test_serde_container_registry_with_credentials() { + let test_json = r#"{"credentials": [{"registry": "foo", "auth": "Ym90dGxlcm9ja2V0"}]}"#; + + let container_registry: RegistrySettingsV1 = serde_json::from_str(test_json).unwrap(); + let credentials = container_registry.credentials.unwrap(); + + assert_eq!(credentials.len(), 1); + assert_eq!( + credentials[0].registry.clone().unwrap(), + SingleLineString::try_from("foo").unwrap(), + ); + assert_eq!( + credentials[0].auth.clone().unwrap(), + ValidBase64::try_from("Ym90dGxlcm9ja2V0").unwrap(), + ); + assert!(credentials[0].username.is_none()); + assert!(credentials[0].password.is_none()); + assert!(credentials[0].identitytoken.is_none()); + } +} diff --git a/sources/settings-extensions/container-registry/src/main.rs b/sources/settings-extensions/container-registry/src/main.rs new file mode 100644 index 00000000000..84801723d3c --- /dev/null +++ b/sources/settings-extensions/container-registry/src/main.rs @@ -0,0 +1,18 @@ +use bottlerocket_settings_sdk::{BottlerocketSetting, NullMigratorExtensionBuilder}; +use settings_extension_container_registry::RegistrySettingsV1; +use std::process::ExitCode; + +fn main() -> ExitCode { + env_logger::init(); + + match NullMigratorExtensionBuilder::with_name("container-registry") + .with_models(vec![BottlerocketSetting::::model()]) + .build() + { + Ok(extension) => extension.run(), + Err(e) => { + println!("{}", e); + ExitCode::FAILURE + } + } +} diff --git a/sources/settings-extensions/motd/Cargo.toml b/sources/settings-extensions/motd/Cargo.toml index 889ef03da63..90d3ac87214 100644 --- a/sources/settings-extensions/motd/Cargo.toml +++ b/sources/settings-extensions/motd/Cargo.toml @@ -13,5 +13,5 @@ string_impls_for = { version = "0.1", path = "../../models/string_impls_for" } [dependencies.bottlerocket-settings-sdk] git = "https://github.com/bottlerocket-os/bottlerocket-settings-sdk" -tag = "bottlerocket-settings-sdk-v0.1.0-alpha.1" +tag = "bottlerocket-settings-sdk-v0.1.0-alpha.2" version = "0.1.0-alpha" diff --git a/sources/settings-extensions/ntp/Cargo.toml b/sources/settings-extensions/ntp/Cargo.toml index d9307a2f90d..eca6c5909d2 100644 --- a/sources/settings-extensions/ntp/Cargo.toml +++ b/sources/settings-extensions/ntp/Cargo.toml @@ -15,5 +15,5 @@ serde_json = "1" [dependencies.bottlerocket-settings-sdk] git = "https://github.com/bottlerocket-os/bottlerocket-settings-sdk" -tag = "bottlerocket-settings-sdk-v0.1.0-alpha.1" +tag = "bottlerocket-settings-sdk-v0.1.0-alpha.2" version = "0.1.0-alpha" From 2c4f8869c76e43069c8d420d0d0c67ce4dae52d8 Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Thu, 7 Dec 2023 00:42:07 +0000 Subject: [PATCH 2/3] settings: use container-registry settings extension in models Signed-off-by: Sam Berning --- sources/Cargo.lock | 15 ++++++++------- sources/models/Cargo.toml | 1 + sources/models/src/aws-dev/mod.rs | 4 ++-- sources/models/src/aws-ecs-1-nvidia/mod.rs | 4 ++-- sources/models/src/aws-ecs-1/mod.rs | 4 ++-- sources/models/src/aws-ecs-2-nvidia/mod.rs | 4 ++-- sources/models/src/aws-ecs-2/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.24-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.24/mod.rs | 5 ++--- sources/models/src/aws-k8s-1.25-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.25/mod.rs | 5 ++--- sources/models/src/aws-k8s-1.26-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.26/mod.rs | 5 ++--- sources/models/src/aws-k8s-1.28-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.28/mod.rs | 5 ++--- sources/models/src/metal-dev/mod.rs | 4 ++-- sources/models/src/metal-k8s-1.24/mod.rs | 4 ++-- sources/models/src/metal-k8s-1.28/mod.rs | 4 ++-- sources/models/src/vmware-dev/mod.rs | 4 ++-- sources/models/src/vmware-k8s-1.24/mod.rs | 4 ++-- sources/models/src/vmware-k8s-1.28/mod.rs | 4 ++-- 21 files changed, 47 insertions(+), 49 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index db6fc771a54..58e146c2c51 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2600,6 +2600,7 @@ dependencies = [ "rand", "serde", "serde_json", + "settings-extension-container-registry", "settings-extension-motd", "settings-extension-ntp", "toml 0.5.11", @@ -3554,29 +3555,29 @@ dependencies = [ ] [[package]] -name = "settings-extension-motd" +name = "settings-extension-container-registry" version = "0.1.0" dependencies = [ "bottlerocket-settings-sdk", + "env_logger", + "model-derive", + "modeled-types", "serde", "serde_json", - "string_impls_for", ] [[package]] -name = "settings-extension-ntp" +name = "settings-extension-motd" version = "0.1.0" dependencies = [ "bottlerocket-settings-sdk", - "env_logger", - "model-derive", - "modeled-types", "serde", "serde_json", + "string_impls_for", ] [[package]] -name = "settings-extension-registry" +name = "settings-extension-ntp" version = "0.1.0" dependencies = [ "bottlerocket-settings-sdk", diff --git a/sources/models/Cargo.toml b/sources/models/Cargo.toml index be4ae0819d3..76c3bffadf5 100644 --- a/sources/models/Cargo.toml +++ b/sources/models/Cargo.toml @@ -20,6 +20,7 @@ toml = "0.5" # settings extensions settings-extension-motd = { path = "../settings-extensions/motd", version = "0.1" } settings-extension-ntp = { path = "../settings-extensions/ntp", version = "0.1" } +settings-extension-container-registry = { path = "../settings-extensions/container-registry", version = "0.1" } [build-dependencies] bottlerocket-variant = { version = "0.1", path = "../bottlerocket-variant" } diff --git a/sources/models/src/aws-dev/mod.rs b/sources/models/src/aws-dev/mod.rs index 993d52075ef..b9c5b4999ae 100644 --- a/sources/models/src/aws-dev/mod.rs +++ b/sources/models/src/aws-dev/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, KernelSettings, MetricsSettings, NetworkSettings, OciHooks, PemCertificate, - RegistrySettings, UpdatesSettings, + UpdatesSettings, }; use modeled_types::Identifier; @@ -23,7 +23,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, dns: DnsSettings, diff --git a/sources/models/src/aws-ecs-1-nvidia/mod.rs b/sources/models/src/aws-ecs-1-nvidia/mod.rs index d7729f411c9..ae4768236c2 100644 --- a/sources/models/src/aws-ecs-1-nvidia/mod.rs +++ b/sources/models/src/aws-ecs-1-nvidia/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, AwsSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, HostContainer, KernelSettings, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -23,7 +23,7 @@ struct Settings { ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-ecs-1/mod.rs b/sources/models/src/aws-ecs-1/mod.rs index d7729f411c9..ae4768236c2 100644 --- a/sources/models/src/aws-ecs-1/mod.rs +++ b/sources/models/src/aws-ecs-1/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, AwsSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, HostContainer, KernelSettings, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -23,7 +23,7 @@ struct Settings { ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-ecs-2-nvidia/mod.rs b/sources/models/src/aws-ecs-2-nvidia/mod.rs index b9e715a6cea..b9ed806c1f5 100644 --- a/sources/models/src/aws-ecs-2-nvidia/mod.rs +++ b/sources/models/src/aws-ecs-2-nvidia/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, HostContainer, KernelSettings, MetricsSettings, NetworkSettings, - OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-ecs-2/mod.rs b/sources/models/src/aws-ecs-2/mod.rs index b9e715a6cea..b9ed806c1f5 100644 --- a/sources/models/src/aws-ecs-2/mod.rs +++ b/sources/models/src/aws-ecs-2/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, HostContainer, KernelSettings, MetricsSettings, NetworkSettings, - OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.24-nvidia/mod.rs b/sources/models/src/aws-k8s-1.24-nvidia/mod.rs index 93c76aaa070..efff4671098 100644 --- a/sources/models/src/aws-k8s-1.24-nvidia/mod.rs +++ b/sources/models/src/aws-k8s-1.24-nvidia/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, - NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.24/mod.rs b/sources/models/src/aws-k8s-1.24/mod.rs index 2cda27e8c06..f760c971443 100644 --- a/sources/models/src/aws-k8s-1.24/mod.rs +++ b/sources/models/src/aws-k8s-1.24/mod.rs @@ -1,8 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, - MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, - UpdatesSettings, + MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -25,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.25-nvidia/mod.rs b/sources/models/src/aws-k8s-1.25-nvidia/mod.rs index 93c76aaa070..efff4671098 100644 --- a/sources/models/src/aws-k8s-1.25-nvidia/mod.rs +++ b/sources/models/src/aws-k8s-1.25-nvidia/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, - NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.25/mod.rs b/sources/models/src/aws-k8s-1.25/mod.rs index 2cda27e8c06..f760c971443 100644 --- a/sources/models/src/aws-k8s-1.25/mod.rs +++ b/sources/models/src/aws-k8s-1.25/mod.rs @@ -1,8 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, - MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, - UpdatesSettings, + MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -25,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.26-nvidia/mod.rs b/sources/models/src/aws-k8s-1.26-nvidia/mod.rs index 93c76aaa070..efff4671098 100644 --- a/sources/models/src/aws-k8s-1.26-nvidia/mod.rs +++ b/sources/models/src/aws-k8s-1.26-nvidia/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, - NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.26/mod.rs b/sources/models/src/aws-k8s-1.26/mod.rs index 2cda27e8c06..f760c971443 100644 --- a/sources/models/src/aws-k8s-1.26/mod.rs +++ b/sources/models/src/aws-k8s-1.26/mod.rs @@ -1,8 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, - MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, - UpdatesSettings, + MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -25,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.28-nvidia/mod.rs b/sources/models/src/aws-k8s-1.28-nvidia/mod.rs index 93c76aaa070..efff4671098 100644 --- a/sources/models/src/aws-k8s-1.28-nvidia/mod.rs +++ b/sources/models/src/aws-k8s-1.28-nvidia/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, - NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/aws-k8s-1.28/mod.rs b/sources/models/src/aws-k8s-1.28/mod.rs index 2cda27e8c06..f760c971443 100644 --- a/sources/models/src/aws-k8s-1.28/mod.rs +++ b/sources/models/src/aws-k8s-1.28/mod.rs @@ -1,8 +1,7 @@ use crate::{ AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, - MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, RegistrySettings, - UpdatesSettings, + MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -25,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, cloudformation: CloudFormationSettings, diff --git a/sources/models/src/metal-dev/mod.rs b/sources/models/src/metal-dev/mod.rs index 1d5fbbae4e0..abf6d0105e4 100644 --- a/sources/models/src/metal-dev/mod.rs +++ b/sources/models/src/metal-dev/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ BootSettings, BootstrapContainer, DnsSettings, HostContainer, KernelSettings, MetricsSettings, - NetworkSettings, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + NetworkSettings, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -21,7 +21,7 @@ struct Settings { boot: BootSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_hooks: OciHooks, dns: DnsSettings, } diff --git a/sources/models/src/metal-k8s-1.24/mod.rs b/sources/models/src/metal-k8s-1.24/mod.rs index f8a58a22cb0..eb593948d62 100644 --- a/sources/models/src/metal-k8s-1.24/mod.rs +++ b/sources/models/src/metal-k8s-1.24/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AwsSettings, BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, NetworkSettings, - OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, dns: DnsSettings, diff --git a/sources/models/src/metal-k8s-1.28/mod.rs b/sources/models/src/metal-k8s-1.28/mod.rs index f8a58a22cb0..eb593948d62 100644 --- a/sources/models/src/metal-k8s-1.28/mod.rs +++ b/sources/models/src/metal-k8s-1.28/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AwsSettings, BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, NetworkSettings, - OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { aws: AwsSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, dns: DnsSettings, diff --git a/sources/models/src/vmware-dev/mod.rs b/sources/models/src/vmware-dev/mod.rs index 1d5fbbae4e0..abf6d0105e4 100644 --- a/sources/models/src/vmware-dev/mod.rs +++ b/sources/models/src/vmware-dev/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ BootSettings, BootstrapContainer, DnsSettings, HostContainer, KernelSettings, MetricsSettings, - NetworkSettings, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + NetworkSettings, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -21,7 +21,7 @@ struct Settings { boot: BootSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_hooks: OciHooks, dns: DnsSettings, } diff --git a/sources/models/src/vmware-k8s-1.24/mod.rs b/sources/models/src/vmware-k8s-1.24/mod.rs index 309de21f4e6..a7590e33d66 100644 --- a/sources/models/src/vmware-k8s-1.24/mod.rs +++ b/sources/models/src/vmware-k8s-1.24/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AwsSettings, BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, NetworkSettings, - OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { boot: BootSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, dns: DnsSettings, diff --git a/sources/models/src/vmware-k8s-1.28/mod.rs b/sources/models/src/vmware-k8s-1.28/mod.rs index 309de21f4e6..a7590e33d66 100644 --- a/sources/models/src/vmware-k8s-1.28/mod.rs +++ b/sources/models/src/vmware-k8s-1.28/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::{ AwsSettings, BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, KernelSettings, KubernetesSettings, MetricsSettings, NetworkSettings, - OciDefaults, OciHooks, PemCertificate, RegistrySettings, UpdatesSettings, + OciDefaults, OciHooks, PemCertificate, UpdatesSettings, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { boot: BootSettings, metrics: MetricsSettings, pki: HashMap, - container_registry: RegistrySettings, + container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, oci_hooks: OciHooks, dns: DnsSettings, From 374f7b2bb9b08072eb5d74b6c761e9b7ef168ed0 Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Mon, 11 Dec 2023 21:01:02 +0000 Subject: [PATCH 3/3] packages: create container-registry settings extension Signed-off-by: Sam Berning --- .../settings-container-registry/Cargo.toml | 21 ++++++++++ .../settings-container-registry.spec | 39 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 packages/settings-container-registry/Cargo.toml create mode 100644 packages/settings-container-registry/settings-container-registry.spec diff --git a/packages/settings-container-registry/Cargo.toml b/packages/settings-container-registry/Cargo.toml new file mode 100644 index 00000000000..756ba266ed1 --- /dev/null +++ b/packages/settings-container-registry/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "settings-container-registry" +version = "0.1.0" +edition = "2021" +publish = false +build = "../build.rs" + +[lib] +path = "../packages.rs" + +[package.metadata.build-package] +source-groups = [ + "settings-extensions/container-registry" +] + +# RPM BuildRequires +[build-dependencies] +glibc = { path = "../glibc" } + +# RPM Requires +[dependencies] diff --git a/packages/settings-container-registry/settings-container-registry.spec b/packages/settings-container-registry/settings-container-registry.spec new file mode 100644 index 00000000000..f2f240a12df --- /dev/null +++ b/packages/settings-container-registry/settings-container-registry.spec @@ -0,0 +1,39 @@ +%global _cross_first_party 1 +%undefine _debugsource_packages + +%global extension_name container-registry + +Name: %{_cross_os}settings-%{extension_name} +Version: 0.0 +Release: 0%{?dist} +Summary: settings-%{extension_name} +License: Apache-2.0 OR MIT +URL: https://github.com/bottlerocket-os/bottlerocket + +BuildRequires: %{_cross_os}glibc-devel + +%description +%{summary}. + +%prep +%setup -T -c +%cargo_prep + +%build +%cargo_build --manifest-path %{_builddir}/sources/Cargo.toml \ + -p settings-extension-%{extension_name} + +%install +install -d %{buildroot}%{_cross_libexecdir} +install -p -m 0755 \ + ${HOME}/.cache/%{__cargo_target}/release/settings-extension-%{extension_name} \ + %{buildroot}%{_cross_libexecdir} + +install -d %{buildroot}%{_cross_libexecdir}/settings +ln -sf \ + ../settings-extension-%{extension_name} \ + %{buildroot}%{_cross_libexecdir}/settings/%{extension_name} + +%files +%{_cross_libexecdir}/settings-extension-%{extension_name} +%{_cross_libexecdir}/settings/%{extension_name}