From bbf5ffa796514d259778dd95687ceb7de6d16334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=BD=20mgsharm?= Date: Tue, 21 May 2024 21:36:54 -0400 Subject: [PATCH 1/3] settings: create oci hooks settings extension --- sources/Cargo.lock | 12 ++++ sources/Cargo.toml | 1 + .../settings-extensions/oci-hooks/Cargo.toml | 19 +++++ .../oci-hooks/oci-hooks.toml | 13 ++++ .../settings-extensions/oci-hooks/src/lib.rs | 72 +++++++++++++++++++ .../settings-extensions/oci-hooks/src/main.rs | 18 +++++ 6 files changed, 135 insertions(+) create mode 100644 sources/settings-extensions/oci-hooks/Cargo.toml create mode 100644 sources/settings-extensions/oci-hooks/oci-hooks.toml create mode 100644 sources/settings-extensions/oci-hooks/src/lib.rs create mode 100644 sources/settings-extensions/oci-hooks/src/main.rs diff --git a/sources/Cargo.lock b/sources/Cargo.lock index 911f038d19f..fe810c49308 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -3973,6 +3973,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "settings-extension-oci-hooks" +version = "0.1.0" +dependencies = [ + "bottlerocket-settings-sdk", + "env_logger", + "model-derive", + "modeled-types", + "serde", + "serde_json", +] + [[package]] name = "settings-extension-pki" version = "0.1.0" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index d2b23f554c0..99877fd8613 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -134,6 +134,7 @@ members = [ "settings-extensions/metrics", "settings-extensions/motd", "settings-extensions/ntp", + "settings-extensions/oci-hooks", "settings-extensions/pki", "settings-extensions/updates", diff --git a/sources/settings-extensions/oci-hooks/Cargo.toml b/sources/settings-extensions/oci-hooks/Cargo.toml new file mode 100644 index 00000000000..352594cea42 --- /dev/null +++ b/sources/settings-extensions/oci-hooks/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "settings-extension-oci-hooks" +version = "0.1.0" +authors = ["Gaurav Sharma "] +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/oci-hooks/oci-hooks.toml b/sources/settings-extensions/oci-hooks/oci-hooks.toml new file mode 100644 index 00000000000..727dfb274cd --- /dev/null +++ b/sources/settings-extensions/oci-hooks/oci-hooks.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/oci-hooks/src/lib.rs b/sources/settings-extensions/oci-hooks/src/lib.rs new file mode 100644 index 00000000000..6ea3e1d05f7 --- /dev/null +++ b/sources/settings-extensions/oci-hooks/src/lib.rs @@ -0,0 +1,72 @@ +/// Settings related to host-provided OCI Hooks +use bottlerocket_settings_sdk::{GenerateResult, SettingsModel}; +use model_derive::model; +use std::convert::Infallible; + +/// The log4j hotpatch functionality is no longer included in Bottlerocket as of v1.15.0. +/// The setting still exists for backwards compatibility. +#[model(impl_default = true)] +pub struct OciHooksSettingsV1 { + log4j_hotpatch_enabled: bool, +} + +type Result = std::result::Result; + +impl SettingsModel for OciHooksSettingsV1 { + type PartialKind = Self; + type ErrorKind = Infallible; + + fn get_version() -> &'static str { + "v1" + } + + fn set(_current_value: Option, _target: Self) -> Result<()> { + // Set anything that can be parsed as OciHooksSettingsV1. + 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<()> { + // OciHooksSettingsV1 is validated during deserialization. + Ok(()) + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_generate_oci_hooks() { + assert_eq!( + OciHooksSettingsV1::generate(None, None).unwrap(), + GenerateResult::Complete(OciHooksSettingsV1 { + log4j_hotpatch_enabled: None, + }) + ) + } + + #[test] + fn test_serde_oci_hooks() { + let test_json = r#"{"log4j-hotpatch-enabled":true}"#; + + let oci_hooks: OciHooksSettingsV1 = serde_json::from_str(test_json).unwrap(); + assert_eq!( + oci_hooks, + OciHooksSettingsV1 { + log4j_hotpatch_enabled: Some(true), + } + ); + + let results = serde_json::to_string(&oci_hooks).unwrap(); + assert_eq!(results, test_json); + } +} diff --git a/sources/settings-extensions/oci-hooks/src/main.rs b/sources/settings-extensions/oci-hooks/src/main.rs new file mode 100644 index 00000000000..52d2d152045 --- /dev/null +++ b/sources/settings-extensions/oci-hooks/src/main.rs @@ -0,0 +1,18 @@ +use bottlerocket_settings_sdk::{BottlerocketSetting, NullMigratorExtensionBuilder}; +use settings_extension_oci_hooks::OciHooksSettingsV1; +use std::process::ExitCode; + +fn main() -> ExitCode { + env_logger::init(); + + match NullMigratorExtensionBuilder::with_name("oci-hooks") + .with_models(vec![BottlerocketSetting::::model()]) + .build() + { + Ok(extension) => extension.run(), + Err(e) => { + println!("{}", e); + ExitCode::FAILURE + } + } +} From 0b389dc5e8089bc683e80bfe5b65563d2814556a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=BD=20mgsharm?= Date: Tue, 21 May 2024 22:01:16 -0400 Subject: [PATCH 2/3] settings: use oci hooks settings extension in models --- sources/Cargo.lock | 1 + 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 | 4 ++-- sources/models/src/aws-k8s-1.25-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.25/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.26-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.26/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.30-nvidia/mod.rs | 4 ++-- sources/models/src/aws-k8s-1.30/mod.rs | 4 ++-- sources/models/src/metal-dev/mod.rs | 6 ++---- sources/models/src/metal-k8s-1.29/mod.rs | 4 ++-- sources/models/src/vmware-dev/mod.rs | 6 ++---- sources/models/src/vmware-k8s-1.30/mod.rs | 4 ++-- 19 files changed, 36 insertions(+), 38 deletions(-) diff --git a/sources/Cargo.lock b/sources/Cargo.lock index fe810c49308..33ae4e4621d 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2823,6 +2823,7 @@ dependencies = [ "settings-extension-metrics", "settings-extension-motd", "settings-extension-ntp", + "settings-extension-oci-hooks", "settings-extension-pki", "settings-extension-updates", "toml", diff --git a/sources/models/Cargo.toml b/sources/models/Cargo.toml index 4c7306dded1..69be425d85c 100644 --- a/sources/models/Cargo.toml +++ b/sources/models/Cargo.toml @@ -24,6 +24,7 @@ settings-extension-kernel = { path = "../settings-extensions/kernel", version = settings-extension-metrics = { path = "../settings-extensions/metrics", version = "0.1" } settings-extension-motd = { path = "../settings-extensions/motd", version = "0.1" } settings-extension-ntp = { path = "../settings-extensions/ntp", version = "0.1" } +settings-extension-oci-hooks = { path = "../settings-extensions/oci-hooks", version = "0.1" } settings-extension-pki = { path = "../settings-extensions/pki", version = "0.1" } settings-extension-updates = { path = "../settings-extensions/updates", version = "0.1" } diff --git a/sources/models/src/aws-dev/mod.rs b/sources/models/src/aws-dev/mod.rs index f75e72813e7..83fc6cd26d7 100644 --- a/sources/models/src/aws-dev/mod.rs +++ b/sources/models/src/aws-dev/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, HostContainer, - NetworkSettings, OciHooks, + NetworkSettings, }; use modeled_types::Identifier; @@ -23,7 +23,7 @@ struct Settings { metrics: settings_extension_metrics::MetricsSettingsV1, pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, 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 81b573f062b..12cb0a3e8c1 100644 --- a/sources/models/src/aws-ecs-1-nvidia/mod.rs +++ b/sources/models/src/aws-ecs-1-nvidia/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, - HostContainer, NetworkSettings, OciDefaults, OciHooks, + HostContainer, NetworkSettings, OciDefaults, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, autoscaling: AutoScalingSettings, dns: DnsSettings, diff --git a/sources/models/src/aws-ecs-1/mod.rs b/sources/models/src/aws-ecs-1/mod.rs index 81b573f062b..12cb0a3e8c1 100644 --- a/sources/models/src/aws-ecs-1/mod.rs +++ b/sources/models/src/aws-ecs-1/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, ECSSettings, - HostContainer, NetworkSettings, OciDefaults, OciHooks, + HostContainer, NetworkSettings, OciDefaults, }; use modeled_types::Identifier; @@ -24,7 +24,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, autoscaling: AutoScalingSettings, dns: DnsSettings, diff --git a/sources/models/src/aws-ecs-2-nvidia/mod.rs b/sources/models/src/aws-ecs-2-nvidia/mod.rs index 3a900eaa581..a3d8a7f2735 100644 --- a/sources/models/src/aws-ecs-2-nvidia/mod.rs +++ b/sources/models/src/aws-ecs-2-nvidia/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, - ECSSettings, HostContainer, NetworkSettings, OciDefaults, OciHooks, + ECSSettings, HostContainer, NetworkSettings, OciDefaults, }; use modeled_types::Identifier; @@ -25,7 +25,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, autoscaling: AutoScalingSettings, dns: DnsSettings, diff --git a/sources/models/src/aws-ecs-2/mod.rs b/sources/models/src/aws-ecs-2/mod.rs index 3a900eaa581..a3d8a7f2735 100644 --- a/sources/models/src/aws-ecs-2/mod.rs +++ b/sources/models/src/aws-ecs-2/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, DnsSettings, - ECSSettings, HostContainer, NetworkSettings, OciDefaults, OciHooks, + ECSSettings, HostContainer, NetworkSettings, OciDefaults, }; use modeled_types::Identifier; @@ -25,7 +25,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, autoscaling: AutoScalingSettings, dns: DnsSettings, 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 913676824f2..4ec451528a8 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, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, diff --git a/sources/models/src/aws-k8s-1.24/mod.rs b/sources/models/src/aws-k8s-1.24/mod.rs index 913676824f2..4ec451528a8 100644 --- a/sources/models/src/aws-k8s-1.24/mod.rs +++ b/sources/models/src/aws-k8s-1.24/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, 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 913676824f2..4ec451528a8 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, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, diff --git a/sources/models/src/aws-k8s-1.25/mod.rs b/sources/models/src/aws-k8s-1.25/mod.rs index 913676824f2..4ec451528a8 100644 --- a/sources/models/src/aws-k8s-1.25/mod.rs +++ b/sources/models/src/aws-k8s-1.25/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, 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 913676824f2..4ec451528a8 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, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, diff --git a/sources/models/src/aws-k8s-1.26/mod.rs b/sources/models/src/aws-k8s-1.26/mod.rs index 913676824f2..4ec451528a8 100644 --- a/sources/models/src/aws-k8s-1.26/mod.rs +++ b/sources/models/src/aws-k8s-1.26/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, diff --git a/sources/models/src/aws-k8s-1.30-nvidia/mod.rs b/sources/models/src/aws-k8s-1.30-nvidia/mod.rs index 913676824f2..4ec451528a8 100644 --- a/sources/models/src/aws-k8s-1.30-nvidia/mod.rs +++ b/sources/models/src/aws-k8s-1.30-nvidia/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, diff --git a/sources/models/src/aws-k8s-1.30/mod.rs b/sources/models/src/aws-k8s-1.30/mod.rs index 913676824f2..4ec451528a8 100644 --- a/sources/models/src/aws-k8s-1.30/mod.rs +++ b/sources/models/src/aws-k8s-1.30/mod.rs @@ -1,7 +1,7 @@ use crate::{ AutoScalingSettings, BootSettings, BootstrapContainer, CloudFormationSettings, ContainerRuntimeSettings, DnsSettings, HostContainer, KubernetesSettings, NetworkSettings, - OciDefaults, OciHooks, + OciDefaults, }; use modeled_types::Identifier; @@ -26,7 +26,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, cloudformation: CloudFormationSettings, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, diff --git a/sources/models/src/metal-dev/mod.rs b/sources/models/src/metal-dev/mod.rs index 89907ac11fb..a50ecc4825a 100644 --- a/sources/models/src/metal-dev/mod.rs +++ b/sources/models/src/metal-dev/mod.rs @@ -1,9 +1,7 @@ use model_derive::model; use std::collections::HashMap; -use crate::{ - BootSettings, BootstrapContainer, DnsSettings, HostContainer, NetworkSettings, OciHooks, -}; +use crate::{BootSettings, BootstrapContainer, DnsSettings, HostContainer, NetworkSettings}; use modeled_types::Identifier; // Note: we have to use 'rename' here because the top-level Settings structure is the only one @@ -21,6 +19,6 @@ struct Settings { metrics: settings_extension_metrics::MetricsSettingsV1, pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, dns: DnsSettings, } diff --git a/sources/models/src/metal-k8s-1.29/mod.rs b/sources/models/src/metal-k8s-1.29/mod.rs index 4f76250fa80..d76a0eadbf1 100644 --- a/sources/models/src/metal-k8s-1.29/mod.rs +++ b/sources/models/src/metal-k8s-1.29/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, - KubernetesSettings, NetworkSettings, OciDefaults, OciHooks, + KubernetesSettings, NetworkSettings, OciDefaults, }; use modeled_types::Identifier; @@ -25,7 +25,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, } diff --git a/sources/models/src/vmware-dev/mod.rs b/sources/models/src/vmware-dev/mod.rs index 89907ac11fb..a50ecc4825a 100644 --- a/sources/models/src/vmware-dev/mod.rs +++ b/sources/models/src/vmware-dev/mod.rs @@ -1,9 +1,7 @@ use model_derive::model; use std::collections::HashMap; -use crate::{ - BootSettings, BootstrapContainer, DnsSettings, HostContainer, NetworkSettings, OciHooks, -}; +use crate::{BootSettings, BootstrapContainer, DnsSettings, HostContainer, NetworkSettings}; use modeled_types::Identifier; // Note: we have to use 'rename' here because the top-level Settings structure is the only one @@ -21,6 +19,6 @@ struct Settings { metrics: settings_extension_metrics::MetricsSettingsV1, pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, dns: DnsSettings, } diff --git a/sources/models/src/vmware-k8s-1.30/mod.rs b/sources/models/src/vmware-k8s-1.30/mod.rs index 3d30b37973a..ee921552bcc 100644 --- a/sources/models/src/vmware-k8s-1.30/mod.rs +++ b/sources/models/src/vmware-k8s-1.30/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use crate::{ BootSettings, BootstrapContainer, ContainerRuntimeSettings, DnsSettings, HostContainer, - KubernetesSettings, NetworkSettings, OciDefaults, OciHooks, + KubernetesSettings, NetworkSettings, OciDefaults, }; use modeled_types::Identifier; @@ -25,7 +25,7 @@ struct Settings { pki: settings_extension_pki::PkiSettingsV1, container_registry: settings_extension_container_registry::RegistrySettingsV1, oci_defaults: OciDefaults, - oci_hooks: OciHooks, + oci_hooks: settings_extension_oci_hooks::OciHooksSettingsV1, dns: DnsSettings, container_runtime: ContainerRuntimeSettings, } From 9caf44f5c715db68aa28670fca82666af37b4110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=BD=20mgsharm?= Date: Tue, 21 May 2024 22:29:10 -0400 Subject: [PATCH 3/3] packages: add oci hooks settings extension package --- packages/settings-oci-hooks/Cargo.toml | 21 ++++++++++ .../settings-oci-hooks.spec | 39 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 packages/settings-oci-hooks/Cargo.toml create mode 100644 packages/settings-oci-hooks/settings-oci-hooks.spec diff --git a/packages/settings-oci-hooks/Cargo.toml b/packages/settings-oci-hooks/Cargo.toml new file mode 100644 index 00000000000..895f86364b6 --- /dev/null +++ b/packages/settings-oci-hooks/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "settings-oci-hooks" +version = "0.1.0" +edition = "2021" +publish = false +build = "../build.rs" + +[lib] +path = "../packages.rs" + +[package.metadata.build-package] +source-groups = [ + "settings-extensions/oci-hooks" +] + +# RPM BuildRequires +[build-dependencies] +glibc = { path = "../glibc" } + +# RPM Requires +[dependencies] diff --git a/packages/settings-oci-hooks/settings-oci-hooks.spec b/packages/settings-oci-hooks/settings-oci-hooks.spec new file mode 100644 index 00000000000..055638b0cf2 --- /dev/null +++ b/packages/settings-oci-hooks/settings-oci-hooks.spec @@ -0,0 +1,39 @@ +%global _cross_first_party 1 +%undefine _debugsource_packages + +%global extension_name oci-hooks + +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}