From 345b7d2616e2719eeba4ea91f2123014f2e251fe Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 14:23:43 +0200 Subject: [PATCH 1/8] deps: add uuid crate 1.23 --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + crates/stackable-operator/Cargo.toml | 1 + 3 files changed, 13 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a2bb5b08e..e696b08b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3029,6 +3029,7 @@ dependencies = [ "tracing-appender", "tracing-subscriber", "url", + "uuid", ] [[package]] @@ -3811,6 +3812,16 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d258b83ceec21034727ecee8c382cfa6c3e133699b0742c64571814fb420c9f7" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "valuable" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index fe90a9506..be9cb1982 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,6 +86,7 @@ tracing-opentelemetry = "0.32.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } trybuild = "1.0.99" url = { version = "2.5.2", features = ["serde"] } +uuid = "1.23" x509-cert = { version = "0.2.5", features = ["builder"] } zeroize = "1.8.1" diff --git a/crates/stackable-operator/Cargo.toml b/crates/stackable-operator/Cargo.toml index 77c6337cb..73c90d65f 100644 --- a/crates/stackable-operator/Cargo.toml +++ b/crates/stackable-operator/Cargo.toml @@ -54,6 +54,7 @@ tracing.workspace = true tracing-appender.workspace = true tracing-subscriber.workspace = true url.workspace = true +uuid.workspace = true [dev-dependencies] indoc.workspace = true From a3829c436faaa93af0e10583a70f0f9c55577630 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 14:24:25 +0200 Subject: [PATCH 2/8] fix: add missing traits; macros and types pub. --- crates/stackable-operator/src/v2/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/stackable-operator/src/v2/mod.rs b/crates/stackable-operator/src/v2/mod.rs index 57eb7a3d8..e0a4b293a 100644 --- a/crates/stackable-operator/src/v2/mod.rs +++ b/crates/stackable-operator/src/v2/mod.rs @@ -1 +1,24 @@ +use crate::v2::types::kubernetes::Uid; + pub mod config_overrides; +pub mod macros; +pub mod types; + +/// Has a non-empty name +/// +/// Useful as an object reference; Should not be used to create an object because the name could +/// violate the naming constraints (e.g. maximum length) of the object. +pub trait HasName { + #[allow(dead_code)] + fn to_name(&self) -> String; +} + +/// Has a Kubernetes UID +pub trait HasUid { + fn to_uid(&self) -> Uid; +} + +/// The name is a valid label value +pub trait NameIsValidLabelValue { + fn to_label_value(&self) -> String; +} From 2c8db8592aae2f53b7c6a0570338aca3c0932998 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 14:24:45 +0200 Subject: [PATCH 3/8] fix: adapt pathes --- .../src/v2/builder/pod/container.rs | 2 +- .../src/v2/macros/attributed_string_type.rs | 106 +++++++++--------- .../src/v2/types/kubernetes.rs | 7 +- 3 files changed, 55 insertions(+), 60 deletions(-) diff --git a/crates/stackable-operator/src/v2/builder/pod/container.rs b/crates/stackable-operator/src/v2/builder/pod/container.rs index f5cb34bc3..8c2e1ef61 100644 --- a/crates/stackable-operator/src/v2/builder/pod/container.rs +++ b/crates/stackable-operator/src/v2/builder/pod/container.rs @@ -11,7 +11,7 @@ use stackable_operator::{ }; use strum::{EnumDiscriminants, IntoStaticStr}; -use crate::framework::types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName}; +use crate::v2::types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName}; #[derive(Snafu, Debug, EnumDiscriminants)] #[strum_discriminants(derive(IntoStaticStr))] diff --git a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs index 26085e94f..2fc9da28e 100644 --- a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs +++ b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs @@ -3,7 +3,7 @@ use strum::{EnumDiscriminants, IntoStaticStr}; /// Maximum length of label values /// -/// Duplicates the private constant [`stackable_operator::kvp::LABEL_VALUE_MAX_LEN`] +/// Duplicates the private constant [`crate::kvp::LABEL_VALUE_MAX_LEN`] pub const MAX_LABEL_VALUE_LENGTH: usize = 63; #[derive(Debug, EnumDiscriminants, Snafu)] @@ -23,24 +23,16 @@ pub enum Error { RegexNotMatched { value: String, regex: &'static str }, #[snafu(display("not a valid label value"))] - InvalidLabelValue { - source: stackable_operator::kvp::LabelValueError, - }, + InvalidLabelValue { source: crate::kvp::LabelValueError }, #[snafu(display("not a valid label name as defined in RFC 1035"))] - InvalidRfc1035LabelName { - source: stackable_operator::validation::Errors, - }, + InvalidRfc1035LabelName { source: crate::validation::Errors }, #[snafu(display("not a valid DNS subdomain name as defined in RFC 1123"))] - InvalidRfc1123DnsSubdomainName { - source: stackable_operator::validation::Errors, - }, + InvalidRfc1123DnsSubdomainName { source: crate::validation::Errors }, #[snafu(display("not a valid label name as defined in RFC 1123"))] - InvalidRfc1123LabelName { - source: stackable_operator::validation::Errors, - }, + InvalidRfc1123LabelName { source: crate::validation::Errors }, #[snafu(display("not a valid UUID"))] InvalidUid { source: uuid::Error }, @@ -106,10 +98,10 @@ macro_rules! attributed_string_type { /// The regular expression /// /// This field is not meant to be used outside of this macro. - pub const REGEX: $crate::framework::macros::attributed_string_type::Regex = attributed_string_type!(@regex $($attribute)*); + pub const REGEX: $crate::v2::macros::attributed_string_type::Regex = attributed_string_type!(@regex $($attribute)*); } - impl stackable_operator::config::merge::Atomic for $name {} + impl crate::config::merge::Atomic for $name {} impl std::fmt::Display for $name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -136,7 +128,7 @@ macro_rules! attributed_string_type { } impl std::str::FromStr for $name { - type Err = $crate::framework::macros::attributed_string_type::Error; + type Err = $crate::v2::macros::attributed_string_type::Error; fn from_str(s: &str) -> std::result::Result { // ResultExt::context is used on most but not all usages of this macro @@ -169,13 +161,13 @@ macro_rules! attributed_string_type { } // The JsonSchema implementation requires `max_length`. - impl stackable_operator::schemars::JsonSchema for $name { + impl crate::schemars::JsonSchema for $name { fn schema_name() -> std::borrow::Cow<'static, str> { std::stringify!($name).into() } - fn json_schema(_generator: &mut stackable_operator::schemars::generate::SchemaGenerator) -> stackable_operator::schemars::Schema { - stackable_operator::schemars::json_schema!({ + fn json_schema(_generator: &mut crate::schemars::generate::SchemaGenerator) -> crate::schemars::Schema { + crate::schemars::json_schema!({ "type": "string", "minLength": $name::MIN_LENGTH, "maxLength": if $name::MAX_LENGTH != usize::MAX { @@ -185,7 +177,7 @@ macro_rules! attributed_string_type { None }, "pattern": match $name::REGEX { - $crate::framework::macros::attributed_string_type::Regex::Expression(regex) => Some(regex), + $crate::v2::macros::attributed_string_type::Regex::Expression(regex) => Some(regex), _ => None } }) @@ -214,7 +206,7 @@ macro_rules! attributed_string_type { let length = $s.len() as usize; snafu::ensure!( length >= $name::MIN_LENGTH, - $crate::framework::macros::attributed_string_type::MinimumLengthNotMetSnafu { + $crate::v2::macros::attributed_string_type::MinimumLengthNotMetSnafu { length, min_length: $name::MIN_LENGTH, } @@ -224,36 +216,36 @@ macro_rules! attributed_string_type { let length = $s.len() as usize; snafu::ensure!( length <= $name::MAX_LENGTH, - $crate::framework::macros::attributed_string_type::LengthExceededSnafu { + $crate::v2::macros::attributed_string_type::LengthExceededSnafu { length, max_length: $name::MAX_LENGTH, } ); }; (@from_str $name:ident, $s:expr, (regex = $regex:expr)) => { - let regex = regex::Regex::new($regex).context($crate::framework::macros::attributed_string_type::InvalidRegexSnafu)?; + let regex = regex::Regex::new($regex).context($crate::v2::macros::attributed_string_type::InvalidRegexSnafu)?; snafu::ensure!( regex.is_match($s), - $crate::framework::macros::attributed_string_type::RegexNotMatchedSnafu { + $crate::v2::macros::attributed_string_type::RegexNotMatchedSnafu { value: $s, regex: $regex } ); }; (@from_str $name:ident, $s:expr, is_rfc_1035_label_name) => { - stackable_operator::validation::is_lowercase_rfc_1035_label($s).context($crate::framework::macros::attributed_string_type::InvalidRfc1035LabelNameSnafu)?; + crate::validation::is_lowercase_rfc_1035_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1035LabelNameSnafu)?; }; (@from_str $name:ident, $s:expr, is_rfc_1123_dns_subdomain_name) => { - stackable_operator::validation::is_lowercase_rfc_1123_subdomain($s).context($crate::framework::macros::attributed_string_type::InvalidRfc1123DnsSubdomainNameSnafu)?; + crate::validation::is_lowercase_rfc_1123_subdomain($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123DnsSubdomainNameSnafu)?; }; (@from_str $name:ident, $s:expr, is_rfc_1123_label_name) => { - stackable_operator::validation::is_lowercase_rfc_1123_label($s).context($crate::framework::macros::attributed_string_type::InvalidRfc1123LabelNameSnafu)?; + crate::validation::is_lowercase_rfc_1123_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123LabelNameSnafu)?; }; (@from_str $name:ident, $s:expr, is_valid_label_value) => { - stackable_operator::kvp::LabelValue::from_str($s).context($crate::framework::macros::attributed_string_type::InvalidLabelValueSnafu)?; + crate::kvp::LabelValue::from_str($s).context($crate::v2::macros::attributed_string_type::InvalidLabelValueSnafu)?; }; (@from_str $name:ident, $s:expr, is_uid) => { - uuid::Uuid::try_parse($s).context($crate::framework::macros::attributed_string_type::InvalidUidSnafu)?; + uuid::Uuid::try_parse($s).context($crate::v2::macros::attributed_string_type::InvalidUidSnafu)?; }; // MIN_LENGTH @@ -263,7 +255,7 @@ macro_rules! attributed_string_type { 0 }; (@min_length (min_length = $min_length:expr) $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::max( + $crate::v2::macros::attributed_string_type::max( $min_length, attributed_string_type!(@min_length $($attribute)*) ) @@ -277,31 +269,31 @@ macro_rules! attributed_string_type { attributed_string_type!(@min_length $($attribute)*) }; (@min_length is_rfc_1035_label_name $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::max( + $crate::v2::macros::attributed_string_type::max( 1, attributed_string_type!(@min_length $($attribute)*) ) }; (@min_length is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::max( + $crate::v2::macros::attributed_string_type::max( 1, attributed_string_type!(@min_length $($attribute)*) ) }; (@min_length is_rfc_1123_label_name $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::max( + $crate::v2::macros::attributed_string_type::max( 1, attributed_string_type!(@min_length $($attribute)*) ) }; (@min_length is_valid_label_value $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::max( + $crate::v2::macros::attributed_string_type::max( 1, attributed_string_type!(@min_length $($attribute)*) ) }; (@min_length is_uid $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::max( + $crate::v2::macros::attributed_string_type::max( uuid::fmt::Hyphenated::LENGTH, attributed_string_type!(@min_length $($attribute)*) ) @@ -318,7 +310,7 @@ macro_rules! attributed_string_type { attributed_string_type!(@max_length $($attribute)*) }; (@max_length (max_length = $max_length:expr) $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::min( + $crate::v2::macros::attributed_string_type::min( $max_length, attributed_string_type!(@max_length $($attribute)*) ) @@ -328,31 +320,31 @@ macro_rules! attributed_string_type { attributed_string_type!(@max_length $($attribute)*) }; (@max_length is_rfc_1035_label_name $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::min( - stackable_operator::validation::RFC_1035_LABEL_MAX_LENGTH, + $crate::v2::macros::attributed_string_type::min( + crate::validation::RFC_1035_LABEL_MAX_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; (@max_length is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::min( - stackable_operator::validation::RFC_1123_SUBDOMAIN_MAX_LENGTH, + $crate::v2::macros::attributed_string_type::min( + crate::validation::RFC_1123_SUBDOMAIN_MAX_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; (@max_length is_rfc_1123_label_name $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::min( - stackable_operator::validation::RFC_1123_LABEL_MAX_LENGTH, + $crate::v2::macros::attributed_string_type::min( + crate::validation::RFC_1123_LABEL_MAX_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; (@max_length is_valid_label_value $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::min( - $crate::framework::macros::attributed_string_type::MAX_LABEL_VALUE_LENGTH, + $crate::v2::macros::attributed_string_type::min( + $crate::v2::macros::attributed_string_type::MAX_LABEL_VALUE_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; (@max_length is_uid $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::min( + $crate::v2::macros::attributed_string_type::min( uuid::fmt::Hyphenated::LENGTH, attributed_string_type!(@max_length $($attribute)*) ) @@ -362,7 +354,7 @@ macro_rules! attributed_string_type { (@regex) => { // Everything is allowed if there is no other regular expression. - $crate::framework::macros::attributed_string_type::Regex::MatchAll + $crate::v2::macros::attributed_string_type::Regex::MatchAll }; (@regex (min_length = $min_length:expr) $($attribute:tt)*) => { // min_length has no influence on the regular expression. @@ -373,31 +365,31 @@ macro_rules! attributed_string_type { attributed_string_type!(@regex $($attribute)*) }; (@regex (regex = $regex:expr) $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::Regex::Expression($regex) + $crate::v2::macros::attributed_string_type::Regex::Expression($regex) .combine(attributed_string_type!(@regex $($attribute)*)) }; (@regex is_rfc_1035_label_name $($attribute:tt)*) => { // see https://github.com/kubernetes/kubernetes/blob/v1.35.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L228 - $crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z]([-a-z0-9]*[a-z0-9])?$") + $crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z]([-a-z0-9]*[a-z0-9])?$") .combine(attributed_string_type!(@regex $($attribute)*)) }; (@regex is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => { // see https://github.com/kubernetes/kubernetes/blob/v1.35.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L193 - $crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$") + $crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$") .combine(attributed_string_type!(@regex $($attribute)*)) }; (@regex is_rfc_1123_label_name $($attribute:tt)*) => { // see https://github.com/kubernetes/kubernetes/blob/v1.35.0/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L163 - $crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") + $crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") .combine(attributed_string_type!(@regex $($attribute)*)) }; (@regex is_valid_label_value $($attribute:tt)*) => { - // regular expression from stackable_operator::kvp::label::LABEL_VALUE_REGEX - $crate::framework::macros::attributed_string_type::Regex::Expression("^[a-z0-9A-Z]([a-z0-9A-Z-_.]*[a-z0-9A-Z]+)?$") + // regular expression from crate::kvp::label::LABEL_VALUE_REGEX + $crate::v2::macros::attributed_string_type::Regex::Expression("^[a-z0-9A-Z]([a-z0-9A-Z-_.]*[a-z0-9A-Z]+)?$") .combine(attributed_string_type!(@regex $($attribute)*)) }; (@regex is_uid $($attribute:tt)*) => { - $crate::framework::macros::attributed_string_type::Regex::Expression("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") + $crate::v2::macros::attributed_string_type::Regex::Expression("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") .combine(attributed_string_type!(@regex $($attribute)*)) }; @@ -432,7 +424,7 @@ macro_rules! attributed_string_type { pub const IS_VALID_LABEL_VALUE: bool = true; } - impl $crate::framework::NameIsValidLabelValue for $name { + impl $crate::v2::NameIsValidLabelValue for $name { fn to_label_value(&self) -> String { self.0.clone() } @@ -490,11 +482,13 @@ mod tests { use std::str::FromStr; use serde_json::{Number, Value, json}; - use stackable_operator::schemars::{JsonSchema, SchemaGenerator}; use uuid::uuid; use super::{ErrorDiscriminants, Regex}; - use crate::framework::NameIsValidLabelValue; + use crate::{ + schemars::{JsonSchema, SchemaGenerator}, + v2::NameIsValidLabelValue, + }; attributed_string_type! { MinLengthWithoutConstraintsTest, diff --git a/crates/stackable-operator/src/v2/types/kubernetes.rs b/crates/stackable-operator/src/v2/types/kubernetes.rs index 861e8a9cf..f7380f327 100644 --- a/crates/stackable-operator/src/v2/types/kubernetes.rs +++ b/crates/stackable-operator/src/v2/types/kubernetes.rs @@ -1,9 +1,10 @@ //! Kubernetes (resource) names use std::str::FromStr; -use stackable_operator::validation::{RFC_1123_LABEL_MAX_LENGTH, RFC_1123_SUBDOMAIN_MAX_LENGTH}; - -use crate::attributed_string_type; +use crate::{ + attributed_string_type, + validation::{RFC_1123_LABEL_MAX_LENGTH, RFC_1123_SUBDOMAIN_MAX_LENGTH}, +}; attributed_string_type! { ConfigMapName, From 89862a78c837911c683627a78696c4c71f2de174 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 14:35:04 +0200 Subject: [PATCH 4/8] fix: make builder pub --- .../stackable-operator/src/v2/builder/meta.rs | 13 ++++---- .../stackable-operator/src/v2/builder/pdb.rs | 28 ++++++++--------- .../src/v2/builder/pod/container.rs | 27 ++++++++--------- .../src/v2/builder/pod/volume.rs | 20 +++++-------- .../src/v2/builder/statefulset.rs | 7 +++-- .../src/v2/macros/attributed_string_type.rs | 30 +++++++++---------- crates/stackable-operator/src/v2/mod.rs | 1 + .../stackable-operator/src/v2/types/common.rs | 6 ++-- 8 files changed, 62 insertions(+), 70 deletions(-) diff --git a/crates/stackable-operator/src/v2/builder/meta.rs b/crates/stackable-operator/src/v2/builder/meta.rs index 5034004f6..95640ba52 100644 --- a/crates/stackable-operator/src/v2/builder/meta.rs +++ b/crates/stackable-operator/src/v2/builder/meta.rs @@ -1,10 +1,10 @@ -use stackable_operator::{ +use crate::{ builder::meta::OwnerReferenceBuilder, - k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference, kube::Resource, + k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference, + kube::Resource, + v2::{HasName, HasUid}, }; -use crate::framework::{HasName, HasUid}; - /// Infallible variant of /// [`stackable_operator::builder::meta::ObjectMetaBuilder::ownerreference_from_resource`] pub fn ownerreference_from_resource( @@ -32,13 +32,12 @@ pub fn ownerreference_from_resource( mod tests { use std::borrow::Cow; - use stackable_operator::{ + use crate::{ k8s_openapi::apimachinery::pkg::apis::meta::v1::{ObjectMeta, OwnerReference}, kube::Resource, + v2::{HasName, HasUid, Uid, builder::meta::ownerreference_from_resource}, }; - use crate::framework::{HasName, HasUid, Uid, builder::meta::ownerreference_from_resource}; - struct Cluster { object_meta: ObjectMeta, } diff --git a/crates/stackable-operator/src/v2/builder/pdb.rs b/crates/stackable-operator/src/v2/builder/pdb.rs index b9c7fdc95..fa18d7bff 100644 --- a/crates/stackable-operator/src/v2/builder/pdb.rs +++ b/crates/stackable-operator/src/v2/builder/pdb.rs @@ -1,12 +1,11 @@ -use stackable_operator::{ +use crate::{ builder::pdb::PodDisruptionBudgetBuilder, k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector, kube::{Resource, api::ObjectMeta}, -}; - -use crate::framework::{ - HasName, HasUid, NameIsValidLabelValue, - types::operator::{ControllerName, OperatorName, ProductName, RoleName}, + v2::{ + HasName, HasUid, NameIsValidLabelValue, + types::operator::{ControllerName, OperatorName, ProductName, RoleName}, + }, }; /// Infallible variant of @@ -35,7 +34,7 @@ pub fn pod_disruption_budget_builder_with_role( mod tests { use std::borrow::Cow; - use stackable_operator::{ + use crate::{ k8s_openapi::{ api::policy::v1::{PodDisruptionBudget, PodDisruptionBudgetSpec}, apimachinery::pkg::{ @@ -44,14 +43,13 @@ mod tests { }, }, kube::Resource, - }; - - use crate::framework::{ - HasName, HasUid, NameIsValidLabelValue, - builder::pdb::pod_disruption_budget_builder_with_role, - types::{ - kubernetes::Uid, - operator::{ControllerName, OperatorName, ProductName, RoleName}, + v2::{ + HasName, HasUid, NameIsValidLabelValue, + builder::pdb::pod_disruption_budget_builder_with_role, + types::{ + kubernetes::Uid, + operator::{ControllerName, OperatorName, ProductName, RoleName}, + }, }, }; diff --git a/crates/stackable-operator/src/v2/builder/pod/container.rs b/crates/stackable-operator/src/v2/builder/pod/container.rs index 8c2e1ef61..166ddb977 100644 --- a/crates/stackable-operator/src/v2/builder/pod/container.rs +++ b/crates/stackable-operator/src/v2/builder/pod/container.rs @@ -5,13 +5,13 @@ use std::{ }; use snafu::Snafu; -use stackable_operator::{ +use strum::{EnumDiscriminants, IntoStaticStr}; + +use crate::{ builder::pod::container::{ContainerBuilder, FieldPathEnvVar}, k8s_openapi::api::core::v1::{ConfigMapKeySelector, EnvVar, EnvVarSource, ObjectFieldSelector}, + v2::types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName}, }; -use strum::{EnumDiscriminants, IntoStaticStr}; - -use crate::v2::types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName}; #[derive(Snafu, Debug, EnumDiscriminants)] #[strum_discriminants(derive(IntoStaticStr))] @@ -38,7 +38,7 @@ impl EnvVarName { /// /// Use this only with constant names that are also tested in unit tests! pub fn from_str_unsafe(s: &str) -> Self { - EnvVarName::from_str(s).expect("should be a valid environment variable name") + Self::from_str(s).expect("should be a valid environment variable name") } } @@ -84,7 +84,7 @@ impl EnvVarSet { /// Moves all [`EnvVar`]s from the given set into this one. /// /// [`EnvVar`]s with the same name are overridden. - pub fn merge(mut self, mut env_var_set: EnvVarSet) -> Self { + pub fn merge(mut self, mut env_var_set: Self) -> Self { self.0.append(&mut env_var_set.0); self @@ -124,7 +124,7 @@ impl EnvVarSet { /// Adds an environment variable with the given name and field path to this set /// /// An [`EnvVar`] with the same name is overridden. - pub fn with_field_path(mut self, name: &EnvVarName, field_path: FieldPathEnvVar) -> Self { + pub fn with_field_path(mut self, name: &EnvVarName, field_path: &FieldPathEnvVar) -> Self { self.0.insert( name.clone(), EnvVar { @@ -191,17 +191,16 @@ impl IntoIterator for EnvVarSet { mod tests { use std::str::FromStr; - use stackable_operator::{ + use super::{EnvVarName, EnvVarSet}; + use crate::{ builder::pod::container::FieldPathEnvVar, k8s_openapi::api::core::v1::{ ConfigMapKeySelector, EnvVar, EnvVarSource, ObjectFieldSelector, }, - }; - - use super::{EnvVarName, EnvVarSet}; - use crate::framework::{ - builder::pod::container::new_container_builder, - types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName}, + v2::{ + builder::pod::container::new_container_builder, + types::kubernetes::{ConfigMapKey, ConfigMapName, ContainerName}, + }, }; #[test] diff --git a/crates/stackable-operator/src/v2/builder/pod/volume.rs b/crates/stackable-operator/src/v2/builder/pod/volume.rs index 06dc48462..a147cf9ba 100644 --- a/crates/stackable-operator/src/v2/builder/pod/volume.rs +++ b/crates/stackable-operator/src/v2/builder/pod/volume.rs @@ -1,10 +1,8 @@ -use stackable_operator::{ +use crate::{ builder::pod::volume::ListenerOperatorVolumeSourceBuilder, - k8s_openapi::api::core::v1::PersistentVolumeClaim, kvp::Labels, -}; - -use crate::framework::types::kubernetes::{ - ListenerClassName, ListenerName, PersistentVolumeClaimName, + k8s_openapi::api::core::v1::PersistentVolumeClaim, + kvp::Labels, + v2::types::kubernetes::{ListenerClassName, ListenerName, PersistentVolumeClaimName}, }; /// Infallible variant of [`stackable_operator::builder::pod::volume::ListenerReference`] @@ -14,18 +12,14 @@ pub enum ListenerReference { Listener(ListenerName), } -impl From<&ListenerReference> for stackable_operator::builder::pod::volume::ListenerReference { +impl From<&ListenerReference> for crate::builder::pod::volume::ListenerReference { fn from(value: &ListenerReference) -> Self { match value { ListenerReference::ListenerClass(listener_class_name) => { - stackable_operator::builder::pod::volume::ListenerReference::ListenerClass( - listener_class_name.to_string(), - ) + Self::ListenerClass(listener_class_name.to_string()) } ListenerReference::Listener(listener_name) => { - stackable_operator::builder::pod::volume::ListenerReference::ListenerName( - listener_name.to_string(), - ) + Self::ListenerName(listener_name.to_string()) } } } diff --git a/crates/stackable-operator/src/v2/builder/statefulset.rs b/crates/stackable-operator/src/v2/builder/statefulset.rs index 904d333b1..5f883ad54 100644 --- a/crates/stackable-operator/src/v2/builder/statefulset.rs +++ b/crates/stackable-operator/src/v2/builder/statefulset.rs @@ -1,8 +1,9 @@ use std::collections::BTreeMap; -use stackable_operator::kvp::Annotations; - -use crate::framework::types::kubernetes::{ConfigMapName, SecretName}; +use crate::{ + kvp::Annotations, + v2::types::kubernetes::{ConfigMapName, SecretName}, +}; /// Creates `restarter.stackable.tech/ignore-configmap.{i}` annotations for each given ConfigMap. /// diff --git a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs index 2fc9da28e..e96b222ec 100644 --- a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs +++ b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs @@ -55,14 +55,14 @@ pub enum Regex { impl Regex { /// Combine this regular expression with the given one. - pub const fn combine(self, other: Regex) -> Regex { + pub const fn combine(self, other: Self) -> Self { match (self, other) { - (_, Regex::MatchAll) => self, - (Regex::MatchAll, _) => other, + (_, Self::MatchAll) => self, + (Self::MatchAll, _) => other, // It is hard to combine two regular expressions and nearly impossible to do this in a // const context. Fortunately, for most of the data types, only one regular expression // is set. - _ => Regex::Unknown, + _ => Self::Unknown, } } } @@ -101,7 +101,7 @@ macro_rules! attributed_string_type { pub const REGEX: $crate::v2::macros::attributed_string_type::Regex = attributed_string_type!(@regex $($attribute)*); } - impl crate::config::merge::Atomic for $name {} + impl $crate::config::merge::Atomic for $name {} impl std::fmt::Display for $name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -161,13 +161,13 @@ macro_rules! attributed_string_type { } // The JsonSchema implementation requires `max_length`. - impl crate::schemars::JsonSchema for $name { + impl $crate::schemars::JsonSchema for $name { fn schema_name() -> std::borrow::Cow<'static, str> { std::stringify!($name).into() } - fn json_schema(_generator: &mut crate::schemars::generate::SchemaGenerator) -> crate::schemars::Schema { - crate::schemars::json_schema!({ + fn json_schema(_generator: &mut $crate::schemars::generate::SchemaGenerator) -> $crate::schemars::Schema { + $crate::schemars::json_schema!({ "type": "string", "minLength": $name::MIN_LENGTH, "maxLength": if $name::MAX_LENGTH != usize::MAX { @@ -233,16 +233,16 @@ macro_rules! attributed_string_type { ); }; (@from_str $name:ident, $s:expr, is_rfc_1035_label_name) => { - crate::validation::is_lowercase_rfc_1035_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1035LabelNameSnafu)?; + $crate::validation::is_lowercase_rfc_1035_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1035LabelNameSnafu)?; }; (@from_str $name:ident, $s:expr, is_rfc_1123_dns_subdomain_name) => { - crate::validation::is_lowercase_rfc_1123_subdomain($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123DnsSubdomainNameSnafu)?; + $crate::validation::is_lowercase_rfc_1123_subdomain($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123DnsSubdomainNameSnafu)?; }; (@from_str $name:ident, $s:expr, is_rfc_1123_label_name) => { - crate::validation::is_lowercase_rfc_1123_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123LabelNameSnafu)?; + $crate::validation::is_lowercase_rfc_1123_label($s).context($crate::v2::macros::attributed_string_type::InvalidRfc1123LabelNameSnafu)?; }; (@from_str $name:ident, $s:expr, is_valid_label_value) => { - crate::kvp::LabelValue::from_str($s).context($crate::v2::macros::attributed_string_type::InvalidLabelValueSnafu)?; + $crate::kvp::LabelValue::from_str($s).context($crate::v2::macros::attributed_string_type::InvalidLabelValueSnafu)?; }; (@from_str $name:ident, $s:expr, is_uid) => { uuid::Uuid::try_parse($s).context($crate::v2::macros::attributed_string_type::InvalidUidSnafu)?; @@ -321,19 +321,19 @@ macro_rules! attributed_string_type { }; (@max_length is_rfc_1035_label_name $($attribute:tt)*) => { $crate::v2::macros::attributed_string_type::min( - crate::validation::RFC_1035_LABEL_MAX_LENGTH, + $crate::validation::RFC_1035_LABEL_MAX_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; (@max_length is_rfc_1123_dns_subdomain_name $($attribute:tt)*) => { $crate::v2::macros::attributed_string_type::min( - crate::validation::RFC_1123_SUBDOMAIN_MAX_LENGTH, + $crate::validation::RFC_1123_SUBDOMAIN_MAX_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; (@max_length is_rfc_1123_label_name $($attribute:tt)*) => { $crate::v2::macros::attributed_string_type::min( - crate::validation::RFC_1123_LABEL_MAX_LENGTH, + $crate::validation::RFC_1123_LABEL_MAX_LENGTH, attributed_string_type!(@max_length $($attribute)*) ) }; diff --git a/crates/stackable-operator/src/v2/mod.rs b/crates/stackable-operator/src/v2/mod.rs index e0a4b293a..852da3fb4 100644 --- a/crates/stackable-operator/src/v2/mod.rs +++ b/crates/stackable-operator/src/v2/mod.rs @@ -1,5 +1,6 @@ use crate::v2::types::kubernetes::Uid; +pub mod builder; pub mod config_overrides; pub mod macros; pub mod types; diff --git a/crates/stackable-operator/src/v2/types/common.rs b/crates/stackable-operator/src/v2/types/common.rs index 3d7326ef1..f63d35f48 100644 --- a/crates/stackable-operator/src/v2/types/common.rs +++ b/crates/stackable-operator/src/v2/types/common.rs @@ -21,13 +21,13 @@ impl std::fmt::Display for Port { impl From for Port { fn from(value: u16) -> Self { - Port(value) + Self(value) } } impl From for i32 { fn from(value: Port) -> Self { - value.0 as i32 + Self::from(value.0) } } @@ -35,7 +35,7 @@ impl TryFrom for Port { type Error = Error; fn try_from(value: i32) -> Result { - Ok(Port( + Ok(Self( u16::try_from(value).context(ConvertToPortNumberSnafu)?, )) } From c53ffca0cc034dd5761c9de1d511cf93ebacd98d Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 14:37:39 +0200 Subject: [PATCH 5/8] fix: make role-utils and role-group-utils pub --- crates/stackable-operator/src/v2/mod.rs | 2 + .../src/v2/role_group_utils.rs | 2 +- .../stackable-operator/src/v2/role_utils.rs | 38 +++++++++---------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/crates/stackable-operator/src/v2/mod.rs b/crates/stackable-operator/src/v2/mod.rs index 852da3fb4..ca7b671fa 100644 --- a/crates/stackable-operator/src/v2/mod.rs +++ b/crates/stackable-operator/src/v2/mod.rs @@ -3,6 +3,8 @@ use crate::v2::types::kubernetes::Uid; pub mod builder; pub mod config_overrides; pub mod macros; +pub mod role_group_utils; +pub mod role_utils; pub mod types; /// Has a non-empty name diff --git a/crates/stackable-operator/src/v2/role_group_utils.rs b/crates/stackable-operator/src/v2/role_group_utils.rs index cb21fafd0..1ce1d025d 100644 --- a/crates/stackable-operator/src/v2/role_group_utils.rs +++ b/crates/stackable-operator/src/v2/role_group_utils.rs @@ -114,7 +114,7 @@ impl ResourceNames { #[cfg(test)] mod tests { use super::{ClusterName, RoleGroupName, RoleName}; - use crate::framework::{ + use crate::v2::{ role_group_utils::{QualifiedRoleGroupName, ResourceNames}, types::kubernetes::{ConfigMapName, ListenerName, ServiceName, StatefulSetName}, }; diff --git a/crates/stackable-operator/src/v2/role_utils.rs b/crates/stackable-operator/src/v2/role_utils.rs index 1ff99ffcc..019e7ddf1 100644 --- a/crates/stackable-operator/src/v2/role_utils.rs +++ b/crates/stackable-operator/src/v2/role_utils.rs @@ -4,15 +4,6 @@ use std::{ }; use serde::{Deserialize, Serialize}; -use stackable_operator::{ - config::{ - fragment::{self, FromFragment}, - merge::{self, Merge, merge}, - }, - k8s_openapi::{DeepMerge, api::core::v1::PodTemplateSpec}, - role_utils::{CommonConfiguration, Role, RoleGroup}, - schemars::{self, JsonSchema}, -}; use super::{ builder::pod::container::EnvVarSet, @@ -21,6 +12,15 @@ use super::{ operator::{ClusterName, ProductName}, }, }; +use crate::{ + config::{ + fragment::{self, FromFragment}, + merge::{self, Merge, merge}, + }, + k8s_openapi::{DeepMerge, api::core::v1::PodTemplateSpec}, + role_utils::{CommonConfiguration, Role, RoleGroup}, + schemars::{self, JsonSchema}, +}; // Variant of [`stackable_operator::role_utils::GenericCommonConfig`] that implements [`Merge`] #[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)] @@ -201,21 +201,21 @@ mod tests { use rstest::*; use serde::Serialize; - use stackable_operator::{ + + use super::ResourceNames; + use crate::{ config::{fragment::Fragment, merge::Merge}, k8s_openapi::api::core::v1::PodTemplateSpec, kube::api::ObjectMeta, role_utils::{CommonConfiguration, GenericRoleConfig, Role, RoleGroup}, schemars::{self, JsonSchema}, - }; - - use super::ResourceNames; - use crate::framework::{ - config_overrides::KeyValueConfigOverrides, - role_utils::with_validated_config, - types::{ - kubernetes::{ClusterRoleName, RoleBindingName, ServiceAccountName}, - operator::{ClusterName, ProductName}, + v2::{ + config_overrides::KeyValueConfigOverrides, + role_utils::with_validated_config, + types::{ + kubernetes::{ClusterRoleName, RoleBindingName, ServiceAccountName}, + operator::{ClusterName, ProductName}, + }, }, }; From e89652dd824baad9588ad8f71cb1f54b9120172f Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 15:07:57 +0200 Subject: [PATCH 6/8] fix: correct fragment and merge macro path --- .../src/v2/builder/pod/container.rs | 4 ++-- crates/stackable-operator/src/v2/role_utils.rs | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/stackable-operator/src/v2/builder/pod/container.rs b/crates/stackable-operator/src/v2/builder/pod/container.rs index 166ddb977..32f5477e6 100644 --- a/crates/stackable-operator/src/v2/builder/pod/container.rs +++ b/crates/stackable-operator/src/v2/builder/pod/container.rs @@ -252,7 +252,7 @@ mod tests { &EnvVarName::from_str_unsafe("ENV2"), "value2 from env_var_set2", ) - .with_field_path(&EnvVarName::from_str_unsafe("ENV3"), FieldPathEnvVar::Name) + .with_field_path(&EnvVarName::from_str_unsafe("ENV3"), &FieldPathEnvVar::Name) .with_value( &EnvVarName::from_str_unsafe("ENV4"), "value4 from env_var_set2", @@ -334,7 +334,7 @@ mod tests { #[test] fn test_envvarset_with_field_path() { let env_var_set = EnvVarSet::new() - .with_field_path(&EnvVarName::from_str_unsafe("ENV"), FieldPathEnvVar::Name); + .with_field_path(&EnvVarName::from_str_unsafe("ENV"), &FieldPathEnvVar::Name); assert_eq!( Some(&EnvVar { diff --git a/crates/stackable-operator/src/v2/role_utils.rs b/crates/stackable-operator/src/v2/role_utils.rs index 019e7ddf1..c925190a5 100644 --- a/crates/stackable-operator/src/v2/role_utils.rs +++ b/crates/stackable-operator/src/v2/role_utils.rs @@ -23,7 +23,7 @@ use crate::{ }; // Variant of [`stackable_operator::role_utils::GenericCommonConfig`] that implements [`Merge`] -#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, JsonSchema, Eq, PartialEq, Serialize)] pub struct GenericCommonConfig {} impl Merge for GenericCommonConfig { @@ -93,7 +93,7 @@ where role_group.config.pod_overrides.clone(), ), product_specific_common_config: merged_product_specific_common_config( - role.config.product_specific_common_config.clone(), + &role.config.product_specific_common_config, role_group.config.product_specific_common_config.clone(), ), }, @@ -138,11 +138,11 @@ fn merged_pod_overrides( merged_pod_overrides } -fn merged_product_specific_common_config(role_config: T, role_group_config: T) -> T +fn merged_product_specific_common_config(role_config: &T, role_group_config: T) -> T where T: Merge, { - merge(role_group_config, &role_config) + merge(role_group_config, role_config) } /// Type-safe names for role resources @@ -220,7 +220,11 @@ mod tests { }; #[derive(Debug, Fragment, PartialEq)] - #[fragment_attrs(derive(Clone, Debug, Default, Merge, PartialEq))] + #[fragment(path_overrides(fragment = "crate::config::fragment"))] + #[fragment_attrs( + derive(Clone, Debug, Default, Merge, PartialEq), + merge(path_overrides(merge = "crate::config::merge")), + )] struct Config { property: String, } @@ -242,6 +246,7 @@ mod tests { } #[derive(Clone, Debug, Default, JsonSchema, Merge, PartialEq, Serialize)] + #[merge(path_overrides(merge = "crate::config::merge"))] struct CommonConfig { property: Option, } From ac08fe856ab941371bb27dcc3746b16b8b5cb13b Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 15:16:21 +0200 Subject: [PATCH 7/8] fix: remaining precommit --- crates/stackable-operator/src/v2/builder/meta.rs | 2 +- crates/stackable-operator/src/v2/builder/pdb.rs | 2 +- .../src/v2/macros/attributed_string_type.rs | 6 +++--- crates/stackable-operator/src/v2/macros/constant.rs | 2 +- crates/stackable-operator/src/v2/role_utils.rs | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/stackable-operator/src/v2/builder/meta.rs b/crates/stackable-operator/src/v2/builder/meta.rs index 95640ba52..e034f5a12 100644 --- a/crates/stackable-operator/src/v2/builder/meta.rs +++ b/crates/stackable-operator/src/v2/builder/meta.rs @@ -44,7 +44,7 @@ mod tests { impl Cluster { fn new() -> Self { - Cluster { + Self { object_meta: ObjectMeta { name: Some("cluster-name".to_owned()), uid: Some("a6b89911-d48e-4328-88d6-b9251226583d".to_owned()), diff --git a/crates/stackable-operator/src/v2/builder/pdb.rs b/crates/stackable-operator/src/v2/builder/pdb.rs index fa18d7bff..81a5c3b39 100644 --- a/crates/stackable-operator/src/v2/builder/pdb.rs +++ b/crates/stackable-operator/src/v2/builder/pdb.rs @@ -59,7 +59,7 @@ mod tests { impl Cluster { fn new() -> Self { - Cluster { + Self { object_meta: ObjectMeta { name: Some("cluster-name".to_owned()), uid: Some("a6b89911-d48e-4328-88d6-b9251226583d".to_owned()), diff --git a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs index e96b222ec..ee0e92fb0 100644 --- a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs +++ b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs @@ -73,7 +73,7 @@ impl Regex { /// /// # Examples /// -/// ```rust +/// ```ignore /// attributed_string_type! { /// ConfigMapName, /// "The name of a ConfigMap", @@ -451,7 +451,7 @@ macro_rules! attributed_string_type { /// /// # Examples /// -/// ```rust +/// ```ignore /// assert_eq!(2, min(2, 3)); /// assert_eq!(4, min(5, 4)); /// assert_eq!(1, min(1, 1)); @@ -466,7 +466,7 @@ pub const fn min(x: usize, y: usize) -> usize { /// /// # Examples /// -/// ```rust +/// ```ignore /// assert_eq!(3, max(2, 3)); /// assert_eq!(5, max(5, 4)); /// assert_eq!(1, max(1, 1)); diff --git a/crates/stackable-operator/src/v2/macros/constant.rs b/crates/stackable-operator/src/v2/macros/constant.rs index ae4e9c69e..3e7170764 100644 --- a/crates/stackable-operator/src/v2/macros/constant.rs +++ b/crates/stackable-operator/src/v2/macros/constant.rs @@ -4,7 +4,7 @@ /// /// # Examples /// -/// ```rust +/// ```ignore /// constant!(DATA_VOLUME_NAME: VolumeName = "data"); /// constant!(pub CONFIG_VOLUME_NAME: VolumeName = "config"); /// ``` diff --git a/crates/stackable-operator/src/v2/role_utils.rs b/crates/stackable-operator/src/v2/role_utils.rs index c925190a5..8394bb77e 100644 --- a/crates/stackable-operator/src/v2/role_utils.rs +++ b/crates/stackable-operator/src/v2/role_utils.rs @@ -222,8 +222,8 @@ mod tests { #[derive(Debug, Fragment, PartialEq)] #[fragment(path_overrides(fragment = "crate::config::fragment"))] #[fragment_attrs( - derive(Clone, Debug, Default, Merge, PartialEq), - merge(path_overrides(merge = "crate::config::merge")), + derive(Clone, Debug, Default, Merge, Eq, PartialEq), + merge(path_overrides(merge = "crate::config::merge")) )] struct Config { property: String, @@ -339,7 +339,7 @@ mod tests { replicas: Some(3) }), result.ok() - ) + ); } #[test] @@ -357,7 +357,7 @@ mod tests { let result: Result, _> = with_validated_config(&role_group, &role, &default_config); - assert!(result.is_err()) + assert!(result.is_err()); } #[test] From e34175875db3658de2ad260ca483d8c686e7e3c3 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 29 May 2026 16:07:29 +0200 Subject: [PATCH 8/8] fix: doc tests --- .../src/v2/macros/attributed_string_type.rs | 11 ++++++++--- crates/stackable-operator/src/v2/macros/constant.rs | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs index ee0e92fb0..7c84b8212 100644 --- a/crates/stackable-operator/src/v2/macros/attributed_string_type.rs +++ b/crates/stackable-operator/src/v2/macros/attributed_string_type.rs @@ -73,7 +73,10 @@ impl Regex { /// /// # Examples /// -/// ```ignore +/// ```rust +/// use std::str::FromStr; +/// +/// use stackable_operator::attributed_string_type; /// attributed_string_type! { /// ConfigMapName, /// "The name of a ConfigMap", @@ -451,7 +454,8 @@ macro_rules! attributed_string_type { /// /// # Examples /// -/// ```ignore +/// ```rust +/// use stackable_operator::v2::macros::attributed_string_type::min; /// assert_eq!(2, min(2, 3)); /// assert_eq!(4, min(5, 4)); /// assert_eq!(1, min(1, 1)); @@ -466,7 +470,8 @@ pub const fn min(x: usize, y: usize) -> usize { /// /// # Examples /// -/// ```ignore +/// ```rust +/// use stackable_operator::{attributed_string_type, v2::macros::attributed_string_type::max}; /// assert_eq!(3, max(2, 3)); /// assert_eq!(5, max(5, 4)); /// assert_eq!(1, max(1, 1)); diff --git a/crates/stackable-operator/src/v2/macros/constant.rs b/crates/stackable-operator/src/v2/macros/constant.rs index 3e7170764..84297a26d 100644 --- a/crates/stackable-operator/src/v2/macros/constant.rs +++ b/crates/stackable-operator/src/v2/macros/constant.rs @@ -4,7 +4,11 @@ /// /// # Examples /// -/// ```ignore +/// ```rust +/// use std::str::FromStr; +/// +/// use stackable_operator::constant; +/// use stackable_operator::v2::types::kubernetes::VolumeName; /// constant!(DATA_VOLUME_NAME: VolumeName = "data"); /// constant!(pub CONFIG_VOLUME_NAME: VolumeName = "config"); /// ```