From cd1459030da14b7743d8d4da2a907d29f02b1f94 Mon Sep 17 00:00:00 2001 From: Ulrich GIRAUD Date: Wed, 1 Jul 2026 10:20:22 +0200 Subject: [PATCH] fix(rbac): Add aggregation labels to the clusterrole Signed-off-by: Ulrich GIRAUD --- .../templates/role.yaml | 3 ++ .../tests/rbac_test.yaml | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 charts/pulsar-resources-operator/tests/rbac_test.yaml diff --git a/charts/pulsar-resources-operator/templates/role.yaml b/charts/pulsar-resources-operator/templates/role.yaml index 5fc656b0..4963dbde 100644 --- a/charts/pulsar-resources-operator/templates/role.yaml +++ b/charts/pulsar-resources-operator/templates/role.yaml @@ -19,6 +19,9 @@ kind: ClusterRole metadata: creationTimestamp: null name: {{ include "pulsar-resources-operator.clusterRoleManagerName" . }} + labels: + rbac.authorization.k8s.io/aggregate-to-edit: "true" + rbac.authorization.k8s.io/aggregate-to-admin: "true" rules: - apiGroups: - "" diff --git a/charts/pulsar-resources-operator/tests/rbac_test.yaml b/charts/pulsar-resources-operator/tests/rbac_test.yaml new file mode 100644 index 00000000..04b2ff4e --- /dev/null +++ b/charts/pulsar-resources-operator/tests/rbac_test.yaml @@ -0,0 +1,42 @@ +# Copyright 2024 StreamNative +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +suite: test rbac +templates: + - role.yaml + - role_binding.yaml +tests: + - it: should pass all default settings + asserts: + - isAPIVersion: + of: rbac.authorization.k8s.io/v1 + - isKind: + of: ClusterRole + template: role.yaml + - isKind: + of: ClusterRoleBinding + template: role_binding.yaml + - matchRegex: + path: metadata.name + pattern: -pulsar-resources-operator + + - it: should reference the agregate to edit and admin roles + asserts: + - template: role.yaml + isSubset: + path: metadata.labels + content: + rbac.authorization.k8s.io/aggregate-to-edit: "true" + rbac.authorization.k8s.io/aggregate-to-admin: "true"