Skip to content

Commit a99d59a

Browse files
committed
changelog, rename resource name functions, role parsing test
1 parent 340bf8d commit a99d59a

6 files changed

Lines changed: 30 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ All notable changes to this project will be documented in this file.
99
- Internal operator refactoring: introduce a build() step in the reconciler that
1010
assembles all relevant Kubernetes resources before anything is applied ([#909]).
1111
- Bump `stackable-operator` to 0.114.0 ([#918]).
12+
- The RBAC ServiceAccount and RoleBinding are now built with the operator-rs `v2::rbac`
13+
functions and carry the full set of recommended labels ([#913]).
1214

1315
[#909]: https://github.com/stackabletech/trino-operator/pull/909
16+
[#913]: https://github.com/stackabletech/trino-operator/pull/913
1417
[#918]: https://github.com/stackabletech/trino-operator/pull/918
1518

1619
## [26.7.0] - 2026-07-21

rust/operator-binary/src/controller/build/resource/config_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn build_rolegroup_config_map(
7474
})?;
7575

7676
let config_map_name = cluster
77-
.resource_names(role, role_group_name)
77+
.role_group_resource_names(role, role_group_name)
7878
.role_group_config_map()
7979
.to_string();
8080

rust/operator-binary/src/controller/build/resource/rbac.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ stackable_operator::constant!(NONE_ROLE_GROUP_NAME: RoleGroupName = "none");
2020
pub fn build_service_account(cluster: &ValidatedCluster) -> ServiceAccount {
2121
rbac::build_service_account(
2222
cluster,
23-
&cluster.rbac_resource_names(),
23+
&cluster.cluster_resource_names(),
2424
rbac_labels(cluster),
2525
)
2626
}
@@ -30,7 +30,7 @@ pub fn build_service_account(cluster: &ValidatedCluster) -> ServiceAccount {
3030
pub fn build_role_binding(cluster: &ValidatedCluster) -> RoleBinding {
3131
rbac::build_role_binding(
3232
cluster,
33-
&cluster.rbac_resource_names(),
33+
&cluster.cluster_resource_names(),
3434
rbac_labels(cluster),
3535
)
3636
}

rust/operator-binary/src/controller/build/resource/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn build_rolegroup_headless_service(
2525
metadata: cluster
2626
.object_meta(
2727
cluster
28-
.resource_names(role, role_group_name)
28+
.role_group_resource_names(role, role_group_name)
2929
.headless_service_name()
3030
.to_string(),
3131
recommended_labels.clone(),
@@ -56,7 +56,7 @@ pub fn build_rolegroup_metrics_service(
5656
metadata: cluster
5757
.object_meta(
5858
cluster
59-
.resource_names(role, role_group_name)
59+
.role_group_resource_names(role, role_group_name)
6060
.metrics_service_name()
6161
.to_string(),
6262
recommended_labels.clone(),

rust/operator-binary/src/controller/build/resource/statefulset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn build_rolegroup_statefulset(
149149
let env_overrides = &role_group_config.env_overrides;
150150
let merged_config = &role_group_config.config;
151151

152-
let resource_names = cluster.resource_names(trino_role, role_group_name);
152+
let resource_names = cluster.role_group_resource_names(trino_role, role_group_name);
153153
let config_map_name = resource_names.role_group_config_map().to_string();
154154

155155
let mut pod_builder = PodBuilder::new();
@@ -423,7 +423,7 @@ pub fn build_rolegroup_statefulset(
423423
.context(AddVolumeSnafu)?
424424
.service_account_name(
425425
cluster
426-
.rbac_resource_names()
426+
.cluster_resource_names()
427427
.service_account_name()
428428
.to_string(),
429429
)

rust/operator-binary/src/controller/mod.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ impl ValidatedCluster {
234234

235235
/// Type-safe names for the per-cluster RBAC resources: the ServiceAccount shared by all
236236
/// Pods, its (namespaced) RoleBinding, and the operator-deployed ClusterRole it binds.
237-
pub fn rbac_resource_names(&self) -> role_utils::ResourceNames {
237+
pub fn cluster_resource_names(&self) -> role_utils::ResourceNames {
238238
role_utils::ResourceNames {
239239
cluster_name: self.name.clone(),
240240
product_name: product_name(),
241241
}
242242
}
243243

244244
/// Type-safe names for the resources of a given role group.
245-
pub(crate) fn resource_names(
245+
pub(crate) fn role_group_resource_names(
246246
&self,
247247
role: &TrinoRole,
248248
role_group_name: &RoleGroupName,
@@ -263,7 +263,7 @@ impl ValidatedCluster {
263263
) -> String {
264264
format!(
265265
"{}-catalog",
266-
self.resource_names(role, role_group_name)
266+
self.role_group_resource_names(role, role_group_name)
267267
.role_group_config_map()
268268
)
269269
}
@@ -465,3 +465,20 @@ pub(crate) fn validated_cluster() -> ValidatedCluster {
465465

466466
validate::validate(&minimal_trino(), &derefs, &operator_env).expect("validate should succeed")
467467
}
468+
469+
#[cfg(test)]
470+
mod tests {
471+
use strum::IntoEnumIterator;
472+
473+
use super::ValidatedCluster;
474+
use crate::crd::TrinoRole;
475+
476+
/// Locks the invariant behind the `expect` in [`ValidatedCluster::role_name`]: every
477+
/// `TrinoRole` variant (present and future) must serialise to a valid `RoleName`.
478+
#[test]
479+
fn every_trino_role_serialises_to_a_valid_role_name() {
480+
for role in TrinoRole::iter() {
481+
ValidatedCluster::role_name(&role);
482+
}
483+
}
484+
}

0 commit comments

Comments
 (0)