Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ All notable changes to this project will be documented in this file.
### Added

- Add the Cargo feature `kube-cel` that enables the `cel` feature on the `kube` crate ([1259]).
- [v2]: Make `ResourceNames::ensure_max_length` public ([#1260]).
- [v2]: Add `MAX_ANNOTATION_NAME_LENGTH` constant with a value of `63` ([#1260]).

[1259]: https://github.com/stackabletech/operator-rs/pull/1259
[#1259]: https://github.com/stackabletech/operator-rs/pull/1259
[#1260]: https://github.com/stackabletech/operator-rs/pull/1260

## [0.115.0] - 2026-08-04

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use strum::{EnumDiscriminants, IntoStaticStr};
/// Duplicates the private constant [`crate::kvp::LABEL_VALUE_MAX_LEN`]
pub const MAX_LABEL_VALUE_LENGTH: usize = 63;

/// Maximum length of annotation names
pub const MAX_ANNOTATION_NAME_LENGTH: usize = 63;
Comment on lines +9 to +10

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant belongs in kvp::annotation.

Rather than exposing the value publicly, it might be cleaner to offer a sanitize function that takes a key prefix and name and returns a valid kvp::key::Key.


#[derive(Debug, EnumDiscriminants, Snafu)]
#[snafu(visibility(pub))]
#[strum_discriminants(derive(IntoStaticStr))]
Expand Down
6 changes: 5 additions & 1 deletion crates/stackable-operator/src/v2/role_group_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ impl ResourceNames {
/// `max_length < 1 /* character */ + 1 /* dash */ + hash_length`.
///
/// Kubernetes object names cannot contain non-ASCII characters.
fn ensure_max_length(resource_name: String, max_length: usize, hash_length: usize) -> String {
pub fn ensure_max_length(
resource_name: String,
max_length: usize,
hash_length: usize,
) -> String {
Comment on lines +102 to +106

@siegfriedweber siegfriedweber Aug 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was written for resource names, where the assertions always hold. If it's now used to shorten arbitrary strings (which could also come from the user) then you can expect the operator to crash.

That said, I do see the usefulness. I'd suggest making it safe for arbitrary strings (which isn't trivial) and moving it to a string utility module.

assert!(resource_name.is_ascii());
assert!(max_length >= 1 /* character */ + 1 /* dash */ + hash_length);

Expand Down
Loading