Skip to content

feat(v2): Make ResourceNames::ensure_max_length public - #1260

Open
sbernauer wants to merge 2 commits into
mainfrom
feat/ensure-max-length-pub
Open

feat(v2): Make ResourceNames::ensure_max_length public#1260
sbernauer wants to merge 2 commits into
mainfrom
feat/ensure-max-length-pub

Conversation

@sbernauer

@sbernauer sbernauer commented Aug 5, 2026

Copy link
Copy Markdown
Member

Description

I need this helper function to fix a bug in commons-operator: stackabletech/commons-operator#443

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

@sbernauer sbernauer self-assigned this Aug 5, 2026
@sbernauer sbernauer moved this to Development: Waiting for Review in Stackable Engineering Aug 5, 2026
@siegfriedweber siegfriedweber moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Aug 5, 2026
@Techassi
Techassi self-requested a review August 5, 2026 15:09
Comment on lines +9 to +10
/// Maximum length of annotation names
pub const MAX_ANNOTATION_NAME_LENGTH: usize = 63;

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.

Comment on lines +102 to +106
pub fn ensure_max_length(
resource_name: String,
max_length: usize,
hash_length: usize,
) -> String {

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: In Review

Development

Successfully merging this pull request may close these issues.

2 participants