Skip to content

Commit af3c19f

Browse files
Check that ensure_max_length is only called with ASCII resource names
1 parent 753bb70 commit af3c19f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

crates/stackable-operator/src/v2/role_group_utils.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl ResourceNames {
7777
"{}-{}-{}",
7878
self.cluster_name, self.role_name, self.role_group_name,
7979
);
80+
// `concatenated_name` contains only ASCII characters.
8081
let sanitized_name = Self::ensure_max_length(
8182
concatenated_name,
8283
QualifiedRoleGroupName::MAX_LENGTH,
@@ -92,8 +93,12 @@ impl ResourceNames {
9293
///
9394
/// # Panics
9495
///
95-
/// Panics if `max_length < 1 /* character */ + 1 /* dash */ + hash_length`.
96+
/// Panics if `resource_name` contains non-ASCII characters or if
97+
/// `max_length < 1 /* character */ + 1 /* dash */ + hash_length`.
98+
///
99+
/// Kubernetes object names cannot contain non-ASCII characters.
96100
fn ensure_max_length(resource_name: String, max_length: usize, hash_length: usize) -> String {
101+
assert!(resource_name.is_ascii());
97102
assert!(max_length >= 1 /* character */ + 1 /* dash */ + hash_length);
98103

99104
if resource_name.len() <= max_length {

0 commit comments

Comments
 (0)