Skip to content
Open
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
20 changes: 20 additions & 0 deletions crates/stackable-operator/src/v2/role_group_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ impl ResourceNames {
.expect("should be a valid Service name")
}

pub fn metrics_service_name(&self) -> ServiceName {
const SUFFIX: &str = "-metrics";

// compile-time checks
const _: () = assert!(
QualifiedRoleGroupName::MAX_LENGTH + SUFFIX.len() <= ServiceName::MAX_LENGTH,
"The string `<cluster_name>-<role_name>-<role_group_name>-metrics` must not exceed the \
limit of Service names."
);
let _ = QualifiedRoleGroupName::IS_RFC_1035_LABEL_NAME;
let _ = QualifiedRoleGroupName::IS_VALID_LABEL_VALUE;

ServiceName::from_str(&format!("{}{SUFFIX}", self.qualified_role_group_name()))
.expect("should be a valid Service name")
}

pub fn listener_name(&self) -> ListenerName {
// compile-time checks
const _: () = assert!(
Expand Down Expand Up @@ -145,6 +161,10 @@ mod tests {
ServiceName::from_str_unsafe("test-cluster-data-nodes-ssd-storage-headless"),
resource_names.headless_service_name()
);
assert_eq!(
ServiceName::from_str_unsafe("test-cluster-data-nodes-ssd-storage-metrics"),
resource_names.metrics_service_name()
);
assert_eq!(
ListenerName::from_str_unsafe("test-cluster-data-nodes-ssd-storage"),
resource_names.listener_name()
Expand Down
Loading