From ef9b4afe811b6d1538136a13a7d630abbb3428bb Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Fri, 26 Jan 2024 00:26:55 +0000 Subject: [PATCH 1/3] settings: create aws settings extension Signed-off-by: Sam Berning --- sources/Cargo.lock | 12 +++ sources/Cargo.toml | 1 + sources/settings-extensions/aws/Cargo.toml | 19 +++++ sources/settings-extensions/aws/aws.toml | 13 ++++ sources/settings-extensions/aws/src/lib.rs | 84 +++++++++++++++++++++ sources/settings-extensions/aws/src/main.rs | 18 +++++ 6 files changed, 147 insertions(+) create mode 100644 sources/settings-extensions/aws/Cargo.toml create mode 100644 sources/settings-extensions/aws/aws.toml create mode 100644 sources/settings-extensions/aws/src/lib.rs create mode 100644 sources/settings-extensions/aws/src/main.rs diff --git a/sources/Cargo.lock b/sources/Cargo.lock index adb7bf455f7..aa887215e1d 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -3648,6 +3648,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "settings-extension-aws" +version = "0.1.0" +dependencies = [ + "bottlerocket-settings-sdk", + "env_logger", + "model-derive", + "modeled-types", + "serde", + "serde_json", +] + [[package]] name = "settings-extension-container-registry" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index d0b6d158134..68c4febcaaf 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -84,6 +84,7 @@ members = [ "models", + "settings-extensions/aws", "settings-extensions/container-registry", "settings-extensions/kernel", "settings-extensions/motd", diff --git a/sources/settings-extensions/aws/Cargo.toml b/sources/settings-extensions/aws/Cargo.toml new file mode 100644 index 00000000000..a073eec4604 --- /dev/null +++ b/sources/settings-extensions/aws/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "settings-extension-aws" +version = "0.1.0" +authors = ["Sam Berning "] +edition = "2021" +license = "Apache-2.0 OR MIT" +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/aws/aws.toml b/sources/settings-extensions/aws/aws.toml new file mode 100644 index 00000000000..727dfb274cd --- /dev/null +++ b/sources/settings-extensions/aws/aws.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/aws/src/lib.rs b/sources/settings-extensions/aws/src/lib.rs new file mode 100644 index 00000000000..08de279ea66 --- /dev/null +++ b/sources/settings-extensions/aws/src/lib.rs @@ -0,0 +1,84 @@ +/// The aws settings can be used to configure settings related to AWS +use bottlerocket_settings_sdk::{GenerateResult, SettingsModel}; +use model_derive::model; +use modeled_types::{SingleLineString, ValidBase64}; +use std::convert::Infallible; + +// Platform-specific settings +#[model(impl_default = true)] +pub struct AwsSettingsV1 { + region: SingleLineString, + config: ValidBase64, + credentials: ValidBase64, + profile: SingleLineString, +} + +type Result = std::result::Result; + +impl SettingsModel for AwsSettingsV1 { + type PartialKind = Self; + type ErrorKind = Infallible; + + fn get_version() -> &'static str { + "v1" + } + + fn set(_current_value: Option, _target: Self) -> Result<()> { + // allow anything that parses as AwsSettingsV1 + 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) -> Result<()> { + Ok(()) + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_generate_aws() { + let generated = AwsSettingsV1::generate(None, None).unwrap(); + assert_eq!( + generated, + GenerateResult::Complete(AwsSettingsV1 { + region: None, + config: None, + credentials: None, + profile: None, + }) + ) + } + + #[test] + fn test_serde_aws() { + let test_json = r#"{ + "region": "us-east-1", + "config": "Zm9vCg==", + "credentials": "Zm9vCg==", + "profile": "foo" + }"#; + + let aws: AwsSettingsV1 = serde_json::from_str(test_json).unwrap(); + + assert_eq!( + aws, + AwsSettingsV1 { + region: Some(SingleLineString::try_from("us-east-1").unwrap()), + config: Some(ValidBase64::try_from("Zm9vCg==").unwrap()), + credentials: Some(ValidBase64::try_from("Zm9vCg==").unwrap()), + profile: Some(SingleLineString::try_from("foo").unwrap()), + } + ); + } +} diff --git a/sources/settings-extensions/aws/src/main.rs b/sources/settings-extensions/aws/src/main.rs new file mode 100644 index 00000000000..4786981b5bb --- /dev/null +++ b/sources/settings-extensions/aws/src/main.rs @@ -0,0 +1,18 @@ +use bottlerocket_settings_sdk::{BottlerocketSetting, NullMigratorExtensionBuilder}; +use settings_extension_aws::AwsSettingsV1; +use std::process::ExitCode; + +fn main() -> ExitCode { + env_logger::init(); + + match NullMigratorExtensionBuilder::with_name("aws") + .with_models(vec![BottlerocketSetting::::model()]) + .build() + { + Ok(extension) => extension.run(), + Err(e) => { + println!("{}", e); + ExitCode::FAILURE + } + } +} From 528e360d6a9c8cfe63f91b9fe7cab06c605f49f2 Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Fri, 26 Jan 2024 00:54:49 +0000 Subject: [PATCH 2/3] settings: use aws settings extension in models Signed-off-by: Sam Berning --- sources/Cargo.lock | 1 + sources/models/Cargo.toml | 1 + sources/models/src/aws-dev/mod.rs | 6 +++--- sources/models/src/aws-ecs-1-nvidia/mod.rs | 7 +++---- sources/models/src/aws-ecs-1/mod.rs | 7 +++---- sources/models/src/aws-ecs-2-nvidia/mod.rs | 8 ++++---- sources/models/src/aws-ecs-2/mod.rs | 8 ++++---- sources/models/src/aws-k8s-1.24-nvidia/mod.rs | 8 ++++---- sources/models/src/aws-k8s-1.24/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.25-nvidia/mod.rs | 8 ++++---- sources/models/src/aws-k8s-1.25/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.26-nvidia/mod.rs | 8 ++++---- sources/models/src/aws-k8s-1.26/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.29-nvidia/mod.rs | 8 ++++---- sources/models/src/aws-k8s-1.29/mod.rs | 4 ++-- sources/models/src/metal-k8s-1.29/mod.rs | 7 +++---- sources/models/src/vmware-k8s-1.29/mod.rs | 7 +++---- 17 files changed, 49 insertions(+), 51 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index aa887215e1d..9a41d54b59a 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2649,6 +2649,7 @@ dependencies = [ "rand", "serde", "serde_json", + "settings-extension-aws", "settings-extension-container-registry", "settings-extension-kernel", "settings-extension-motd", diff --git a/sources/models/Cargo.toml b/sources/models/Cargo.toml index a2c49634383..e40e7b0ceda 100644 --- a/sources/models/Cargo.toml +++ b/sources/models/Cargo.toml @@ -18,6 +18,7 @@ serde = { version = "1", features = ["derive"] } toml = "0.5" # settings extensions +settings-extension-aws = { path = "../settings-extensions/aws", version = "0.1" } settings-extension-container-registry = { path = "../settings-extensions/container-registry", version = "0.1" } settings-extension-kernel = { path = "../settings-extensions/kernel", version = "0.1" } settings-extension-motd = { path = "../settings-extensions/motd", version = "0.1" } diff --git a/sources/models/src/aws-dev/mod.rs b/sources/models/src/aws-dev/mod.rs index 1f070578fc8..47117cfabcb 100644 --- a/sources/models/src/aws-dev/mod.rs +++ b/sources/models/src/aws-dev/mod.rs @@ -2,8 +2,8 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, - HostContainer, MetricsSettings, NetworkSettings, OciHooks, PemCertificate, + BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, + MetricsSettings, NetworkSettings, OciHooks, PemCertificate, }; use modeled_types::Identifier; @@ -19,7 +19,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/aws-ecs-1-nvidia/mod.rs b/sources/models/src/aws-ecs-1-nvidia/mod.rs index b599043af0c..7804e8319f6 100644 --- a/sources/models/src/aws-ecs-1-nvidia/mod.rs +++ b/sources/models/src/aws-ecs-1-nvidia/mod.rs @@ -2,9 +2,8 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AutoScalingSettings, AwsSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, - ECSSettings, HostContainer, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, - PemCertificate, + AutoScalingSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, + HostContainer, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; use modeled_types::Identifier; @@ -19,7 +18,7 @@ struct Settings { ntp: settings_extension_ntp::NtpSettingsV1, network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, diff --git a/sources/models/src/aws-ecs-1/mod.rs b/sources/models/src/aws-ecs-1/mod.rs index b599043af0c..7804e8319f6 100644 --- a/sources/models/src/aws-ecs-1/mod.rs +++ b/sources/models/src/aws-ecs-1/mod.rs @@ -2,9 +2,8 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AutoScalingSettings, AwsSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, - ECSSettings, HostContainer, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, - PemCertificate, + AutoScalingSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, + HostContainer, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; use modeled_types::Identifier; @@ -19,7 +18,7 @@ struct Settings { ntp: settings_extension_ntp::NtpSettingsV1, network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, diff --git a/sources/models/src/aws-ecs-2-nvidia/mod.rs b/sources/models/src/aws-ecs-2-nvidia/mod.rs index 001c3de02e6..2e3e8ec2848 100644 --- a/sources/models/src/aws-ecs-2-nvidia/mod.rs +++ b/sources/models/src/aws-ecs-2-nvidia/mod.rs @@ -2,9 +2,9 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, - DnsSettings, ECSSettings, HostContainer, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, + ECSSettings, HostContainer, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, + PemCertificate, }; use modeled_types::Identifier; @@ -20,7 +20,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, diff --git a/sources/models/src/aws-ecs-2/mod.rs b/sources/models/src/aws-ecs-2/mod.rs index 001c3de02e6..2e3e8ec2848 100644 --- a/sources/models/src/aws-ecs-2/mod.rs +++ b/sources/models/src/aws-ecs-2/mod.rs @@ -2,9 +2,9 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, - DnsSettings, ECSSettings, HostContainer, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, + ECSSettings, HostContainer, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, + PemCertificate, }; use modeled_types::Identifier; @@ -20,7 +20,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, ecs: ECSSettings, metrics: MetricsSettings, pki: HashMap, 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 5a391aa6b1a..2e208b31fad 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, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, + HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, + PemCertificate, }; use modeled_types::Identifier; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/aws-k8s-1.24/mod.rs b/sources/models/src/aws-k8s-1.24/mod.rs index a7d022ed272..890f4399313 100644 --- a/sources/models/src/aws-k8s-1.24/mod.rs +++ b/sources/models/src/aws-k8s-1.24/mod.rs @@ -1,5 +1,5 @@ use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, 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 5a391aa6b1a..2e208b31fad 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, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, + HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, + PemCertificate, }; use modeled_types::Identifier; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/aws-k8s-1.25/mod.rs b/sources/models/src/aws-k8s-1.25/mod.rs index a7d022ed272..890f4399313 100644 --- a/sources/models/src/aws-k8s-1.25/mod.rs +++ b/sources/models/src/aws-k8s-1.25/mod.rs @@ -1,5 +1,5 @@ use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, 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 5a391aa6b1a..2e208b31fad 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, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, + HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, + PemCertificate, }; use modeled_types::Identifier; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/aws-k8s-1.26/mod.rs b/sources/models/src/aws-k8s-1.26/mod.rs index a7d022ed272..890f4399313 100644 --- a/sources/models/src/aws-k8s-1.26/mod.rs +++ b/sources/models/src/aws-k8s-1.26/mod.rs @@ -1,5 +1,5 @@ use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/aws-k8s-1.29-nvidia/mod.rs b/sources/models/src/aws-k8s-1.29-nvidia/mod.rs index 5a391aa6b1a..2e208b31fad 100644 --- a/sources/models/src/aws-k8s-1.29-nvidia/mod.rs +++ b/sources/models/src/aws-k8s-1.29-nvidia/mod.rs @@ -1,7 +1,7 @@ use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, - DnsSettings, HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, - OciHooks, PemCertificate, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, + HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, + PemCertificate, }; use modeled_types::Identifier; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/aws-k8s-1.29/mod.rs b/sources/models/src/aws-k8s-1.29/mod.rs index a7d022ed272..890f4399313 100644 --- a/sources/models/src/aws-k8s-1.29/mod.rs +++ b/sources/models/src/aws-k8s-1.29/mod.rs @@ -1,5 +1,5 @@ use crate::{ - AutoScalingSettings, AwsSettings, BootSettings, BootstrapContainer, CloudFormationSettings, + AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; @@ -21,7 +21,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/metal-k8s-1.29/mod.rs b/sources/models/src/metal-k8s-1.29/mod.rs index 1878cf61c82..50c7a805e52 100644 --- a/sources/models/src/metal-k8s-1.29/mod.rs +++ b/sources/models/src/metal-k8s-1.29/mod.rs @@ -2,9 +2,8 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AwsSettings, BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, - HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, - PemCertificate, + BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, + KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; use modeled_types::Identifier; @@ -21,7 +20,7 @@ struct Settings { network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, boot: BootSettings, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, metrics: MetricsSettings, pki: HashMap, container_registry: settings_extension_container_registry::RegistrySettingsV1, diff --git a/sources/models/src/vmware-k8s-1.29/mod.rs b/sources/models/src/vmware-k8s-1.29/mod.rs index e2313733535..9998f2f7ce2 100644 --- a/sources/models/src/vmware-k8s-1.29/mod.rs +++ b/sources/models/src/vmware-k8s-1.29/mod.rs @@ -2,9 +2,8 @@ use model_derive::model; use std::collections::HashMap; use crate::{ - AwsSettings, BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, - HostContainer, KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, - PemCertificate, + BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, + KubernetesSettings, MetricsSettings, NetworkSettings, OciDefaults, OciHooks, PemCertificate, }; use modeled_types::Identifier; @@ -20,7 +19,7 @@ struct Settings { ntp: settings_extension_ntp::NtpSettingsV1, network: NetworkSettings, kernel: settings_extension_kernel::KernelSettingsV1, - aws: AwsSettings, + aws: settings_extension_aws::AwsSettingsV1, boot: BootSettings, metrics: MetricsSettings, pki: HashMap, From 6f870f045b8ff72b1ba465fa9b9f5982305685e3 Mon Sep 17 00:00:00 2001 From: Sam Berning Date: Fri, 26 Jan 2024 00:58:56 +0000 Subject: [PATCH 3/3] packages: add aws settings extension package Signed-off-by: Sam Berning --- packages/settings-aws/Cargo.toml | 21 +++++++++++++ packages/settings-aws/settings-aws.spec | 39 +++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 packages/settings-aws/Cargo.toml create mode 100644 packages/settings-aws/settings-aws.spec diff --git a/packages/settings-aws/Cargo.toml b/packages/settings-aws/Cargo.toml new file mode 100644 index 00000000000..d2313575330 --- /dev/null +++ b/packages/settings-aws/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "settings-aws" +version = "0.1.0" +edition = "2021" +publish = false +build = "../build.rs" + +[lib] +path = "../packages.rs" + +[package.metadata.build-package] +source-groups = [ + "settings-extensions/aws" +] + +# RPM BuildRequires +[build-dependencies] +glibc = { path = "../glibc" } + +# RPM Requires +[dependencies] diff --git a/packages/settings-aws/settings-aws.spec b/packages/settings-aws/settings-aws.spec new file mode 100644 index 00000000000..d0224fffe00 --- /dev/null +++ b/packages/settings-aws/settings-aws.spec @@ -0,0 +1,39 @@ +%global _cross_first_party 1 +%undefine _debugsource_packages + +%global extension_name aws + +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}