From 1e1647100b8671f7741cbb85cc06c617201a5aa1 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Thu, 10 Sep 2026 17:30:39 +0200 Subject: [PATCH 1/2] replace deref with accessor function --- .../build/resource/daemonset/mod.rs | 19 ++++++++----------- .../daemonset/resource_info_fetcher.rs | 2 +- .../resource/daemonset/user_info_fetcher.rs | 2 +- rust/operator-binary/src/crd/mod.rs | 18 +++++++----------- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/rust/operator-binary/src/controller/build/resource/daemonset/mod.rs b/rust/operator-binary/src/controller/build/resource/daemonset/mod.rs index dfd396fb..9ab659e9 100644 --- a/rust/operator-binary/src/controller/build/resource/daemonset/mod.rs +++ b/rust/operator-binary/src/controller/build/resource/daemonset/mod.rs @@ -45,7 +45,7 @@ use stackable_operator::{ product_logging::framework::{ STACKABLE_LOG_DIR, ValidatedContainerLogConfigChoice, vector_container, }, - types::kubernetes::{ContainerName, VolumeName}, + types::kubernetes::VolumeName, }, }; @@ -283,20 +283,17 @@ pub fn build_server_rolegroup_daemonset( let mut pb = PodBuilder::new(); - let prepare_container_name: &ContainerName = &Container::Prepare; - let mut cb_prepare = new_container_builder(prepare_container_name); + let mut cb_prepare = new_container_builder(Container::Prepare.name()); - let bundle_builder_container_name: &ContainerName = &Container::BundleBuilder; - let mut cb_bundle_builder = new_container_builder(bundle_builder_container_name); + let mut cb_bundle_builder = new_container_builder(Container::BundleBuilder.name()); - let opa_container_name: &ContainerName = &Container::Opa; - let mut cb_opa = new_container_builder(opa_container_name); + let mut cb_opa = new_container_builder(Container::Opa.name()); cb_prepare .image_from_product_image(resolved_product_image) .command(bash_entrypoint_command()) .args(vec![ - build_prepare_start_command(merged_config, prepare_container_name.as_ref()) + build_prepare_start_command(merged_config, Container::Prepare.name().as_ref()) .join(" && "), ]) .add_volume_mount(BUNDLES_VOLUME_NAME.as_ref(), BUNDLES_DIR) @@ -321,7 +318,7 @@ pub fn build_server_rolegroup_daemonset( .command(bash_entrypoint_command()) .args(vec![build_bundle_builder_start_command( merged_config, - bundle_builder_container_name.as_ref(), + Container::BundleBuilder.name().as_ref(), )]) .add_env_vars(bundle_builder_env_vars) .add_volume_mount(BUNDLES_VOLUME_NAME.as_ref(), BUNDLES_DIR) @@ -355,7 +352,7 @@ pub fn build_server_rolegroup_daemonset( .command(bash_entrypoint_command()) .args(vec![build_opa_start_command( merged_config, - opa_container_name.as_ref(), + Container::Opa.name().as_ref(), cluster.is_tls_enabled(), &rolegroup_config.cli_overrides, )]) @@ -504,7 +501,7 @@ pub fn build_server_rolegroup_daemonset( // the Vector agent is enabled and the aggregator discovery ConfigMap name is valid. if let Some(vector_log_config) = &merged_config.logging.vector_container { pb.add_container(vector_container( - &Container::Vector, + Container::Vector.name(), resolved_product_image, vector_log_config, &cluster.role_group_resource_names(role_group_name), diff --git a/rust/operator-binary/src/controller/build/resource/daemonset/resource_info_fetcher.rs b/rust/operator-binary/src/controller/build/resource/daemonset/resource_info_fetcher.rs index 19d8c2fe..d9205373 100644 --- a/rust/operator-binary/src/controller/build/resource/daemonset/resource_info_fetcher.rs +++ b/rust/operator-binary/src/controller/build/resource/daemonset/resource_info_fetcher.rs @@ -57,7 +57,7 @@ pub fn add_resource_info_fetcher_sidecar( cluster_info: &KubernetesClusterInfo, ) -> Result<()> { if let Some(resource_info) = &cluster.cluster_config.resource_info { - let mut cb_rif = new_container_builder(&Container::ResourceInfoFetcher); + let mut cb_rif = new_container_builder(Container::ResourceInfoFetcher.name()); // All operator-set environment variables of the resource-info-fetcher container, collected // into an `EnvVarSet` so that every name occurs only once. diff --git a/rust/operator-binary/src/controller/build/resource/daemonset/user_info_fetcher.rs b/rust/operator-binary/src/controller/build/resource/daemonset/user_info_fetcher.rs index 300d73da..70ef1765 100644 --- a/rust/operator-binary/src/controller/build/resource/daemonset/user_info_fetcher.rs +++ b/rust/operator-binary/src/controller/build/resource/daemonset/user_info_fetcher.rs @@ -87,7 +87,7 @@ pub fn add_user_info_fetcher_sidecar( cluster_info: &KubernetesClusterInfo, ) -> Result<()> { if let Some(user_info) = &cluster.cluster_config.user_info { - let mut cb_user_info_fetcher = new_container_builder(&Container::UserInfoFetcher); + let mut cb_user_info_fetcher = new_container_builder(Container::UserInfoFetcher.name()); // All operator-set environment variables of the user-info-fetcher container, collected // into an `EnvVarSet` so that every name occurs only once. The backend match below may diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index 4b98649c..e7054aeb 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -228,10 +228,9 @@ constant!(OPA_CONTAINER_NAME: ContainerName = "opa"); constant!(USER_INFO_FETCHER_CONTAINER_NAME: ContainerName = "user-info-fetcher"); constant!(RESOURCE_INFO_FETCHER_CONTAINER_NAME: ContainerName = "resource-info-fetcher"); -impl Deref for Container { - type Target = ContainerName; - - fn deref(&self) -> &Self::Target { +impl Container { + /// The typed container name of this variant. + pub fn name(&self) -> &'static ContainerName { match self { Container::Prepare => &PREPARE_CONTAINER_NAME, Container::Vector => &VECTOR_CONTAINER_NAME, @@ -355,9 +354,7 @@ impl HasStatusCondition for v1alpha2::OpaCluster { #[cfg(test)] mod tests { use indoc::formatdoc; - use stackable_operator::{ - v2::types::kubernetes::ContainerName, versioned::test_utils::RoundtripTestData, - }; + use stackable_operator::versioned::test_utils::RoundtripTestData; use strum::IntoEnumIterator; use super::{ @@ -378,13 +375,12 @@ mod tests { let _ = *RESOURCE_INFO_FETCHER_CONTAINER_NAME; } - /// The typed container names behind `Container`'s `Deref` must agree with its strum - /// `Display`, which the logging configuration still uses as the per-container key. + /// The typed container names returned by `name` must agree with the strum `Display` + /// of `Container`, which the logging configuration still uses as the per-container key. #[test] fn container_names_match_display() { for container in Container::iter() { - let container_name: &ContainerName = &container; - assert_eq!(container_name.to_string(), container.to_string()); + assert_eq!(container.name().to_string(), container.to_string()); } } From 1cda63380372f5b235cd19c8ae4402a6431f9271 Mon Sep 17 00:00:00 2001 From: Andrew Kenworthy Date: Thu, 10 Sep 2026 17:38:28 +0200 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e9d9e2a..de080367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,7 @@ All notable changes to this project will be documented in this file. deletion is required ([#880]). - The operator now watches all resources that it creates and early-exits the reconcile action when the cluster is marked for deletion ([#882]). -- Make operations infallible where dependent on static inputs ([#886]). +- Make operations infallible where dependent on static inputs ([#886], [#889]). ### Fixed @@ -83,6 +83,7 @@ All notable changes to this project will be documented in this file. [#880]: https://github.com/stackabletech/opa-operator/pull/880 [#882]: https://github.com/stackabletech/opa-operator/pull/882 [#886]: https://github.com/stackabletech/opa-operator/pull/886 +[#889]: https://github.com/stackabletech/opa-operator/pull/889 ## [26.7.0] - 2026-07-21