From 52626e7e0a66b423f62b187f659bf5630e696bd6 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 27 Mar 2026 15:06:20 +0100 Subject: [PATCH 1/4] chore(operator)!: Remove unused kvp::Key function to mutate inner values --- crates/stackable-operator/src/kvp/key.rs | 30 ------------------------ 1 file changed, 30 deletions(-) diff --git a/crates/stackable-operator/src/kvp/key.rs b/crates/stackable-operator/src/kvp/key.rs index 6e2486f63..bf9f686b2 100644 --- a/crates/stackable-operator/src/kvp/key.rs +++ b/crates/stackable-operator/src/kvp/key.rs @@ -126,21 +126,6 @@ impl Key { self.prefix.as_ref() } - /// Adds or replaces the key prefix. This takes a parsed and validated - /// [`KeyPrefix`] as a parameter. If instead you want to use a raw value, - /// use the [`Key::try_add_prefix()`] function instead. - pub fn add_prefix(&mut self, prefix: KeyPrefix) { - self.prefix = Some(prefix) - } - - /// Adds or replaces the key prefix by parsing and validation raw input. If - /// instead you already have a parsed and validated [`KeyPrefix`], use the - /// [`Key::add_prefix()`] function instead. - pub fn try_add_prefix(&mut self, prefix: impl AsRef) -> Result<&mut Self, KeyError> { - self.prefix = Some(KeyPrefix::from_str(prefix.as_ref()).context(KeyPrefixSnafu)?); - Ok(self) - } - /// Retrieves the key's name. /// /// ``` @@ -156,21 +141,6 @@ impl Key { pub fn name(&self) -> &KeyName { &self.name } - - /// Sets the key name. This takes a parsed and validated [`KeyName`] as a - /// parameter. If instead you want to use a raw value, use the - /// [`Key::try_set_name()`] function instead. - pub fn set_name(&mut self, name: KeyName) { - self.name = name - } - - /// Sets the key name by parsing and validation raw input. If instead you - /// already have a parsed and validated [`KeyName`], use the - /// [`Key::set_name()`] function instead. - pub fn try_set_name(&mut self, name: impl AsRef) -> Result<&mut Self, KeyError> { - self.name = KeyName::from_str(name.as_ref()).context(KeyNameSnafu)?; - Ok(self) - } } /// The error type for key prefix parsing/validation operations. From 7216ace2c452cf79c8d71277b35d8007b465ce0f Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 27 Mar 2026 15:12:01 +0100 Subject: [PATCH 2/4] feat(operator): Implement Deref for kvp::Key --- crates/stackable-operator/src/kvp/key.rs | 43 +++++++++++++++++++----- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/crates/stackable-operator/src/kvp/key.rs b/crates/stackable-operator/src/kvp/key.rs index bf9f686b2..ed280bea9 100644 --- a/crates/stackable-operator/src/kvp/key.rs +++ b/crates/stackable-operator/src/kvp/key.rs @@ -58,6 +58,16 @@ pub enum KeyError { /// [k8s-labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Key { + /// A cached and formatted representation of a [`Key`] as a [`String`], which enables the + /// implementation of [`Deref`], instead of constructing a new [`String`] every time the string + /// representation of a key is needed. + /// + /// ### Safety + /// + /// This is safe to do (and cache it), because [`Key`] doesn't provide any **mutable** access + /// to the inner values. + string: String, + prefix: Option, name: KeyName, } @@ -80,12 +90,22 @@ impl FromStr for Key { _ => return NestedPrefixSnafu.fail(), }; + let prefix = prefix + .map(KeyPrefix::from_str) + .transpose() + .context(KeyPrefixSnafu)?; + + let name = KeyName::from_str(name).context(KeyNameSnafu)?; + + let string = match prefix { + Some(ref prefix) => format!("{prefix}/{name}"), + None => format!("{name}"), + }; + let key = Self { - prefix: prefix - .map(KeyPrefix::from_str) - .transpose() - .context(KeyPrefixSnafu)?, - name: KeyName::from_str(name).context(KeyNameSnafu)?, + string, + prefix, + name, }; Ok(key) @@ -102,10 +122,15 @@ impl TryFrom<&str> for Key { impl Display for Key { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match &self.prefix { - Some(prefix) => write!(f, "{}/{}", prefix, self.name), - None => write!(f, "{}", self.name), - } + write!(f, "{key}", key = self.string) + } +} + +impl Deref for Key { + type Target = str; + + fn deref(&self) -> &Self::Target { + self.string.as_str() } } From 783c44310e8ba41dc8aa1208276dff017b3fd7a9 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 27 Mar 2026 16:03:16 +0100 Subject: [PATCH 3/4] fix: Bump rustls-webpki to 0.103.10 to negate RUSTSEC-2026-0049 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9032146e..d9a41cd7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2529,9 +2529,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.9" +version = "0.103.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef" dependencies = [ "ring", "rustls-pki-types", From fd7e27dc01c09ce065616739b256b53fe33054f5 Mon Sep 17 00:00:00 2001 From: Techassi Date: Fri, 27 Mar 2026 16:16:07 +0100 Subject: [PATCH 4/4] chore: Add changelog entries --- crates/stackable-operator/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index b9fb62d3b..e7fa5cc1f 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -6,10 +6,17 @@ All notable changes to this project will be documented in this file. ### Added +- Implement `Deref` for `kvp::Key` to be more ergonomic to use ([#1182]). - Add support for specifying a `clientAuthenticationMethod` for OIDC ([#1178]). This was originally done in [#1158] and had been reverted in [#1170]. +### Removed + +- BREAKING: Remove unused `add_prefix`, `try_add_prefix`, `set_name`, and `try_set_name` associated + functions from `kvp::Key` to disallow mutable access to inner values ([#1182]). + [#1178]: https://github.com/stackabletech/operator-rs/pull/1178 +[#1182]: https://github.com/stackabletech/operator-rs/pull/1182 ## [0.108.0] - 2026-03-10