From 347f379d8f2683e7e5aa78f33a331d66247f04b4 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Tue, 26 Dec 2023 14:22:34 +0200 Subject: [PATCH] fix(rbac): adds resourceNames --- library/common-test/tests/rbac/data_test.yaml | 4 ++++ library/common/Chart.yaml | 2 +- library/common/templates/lib/rbac/_rules.tpl | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/library/common-test/tests/rbac/data_test.yaml b/library/common-test/tests/rbac/data_test.yaml index e2114147..289fb4f7 100644 --- a/library/common-test/tests/rbac/data_test.yaml +++ b/library/common-test/tests/rbac/data_test.yaml @@ -35,6 +35,8 @@ tests: - "{{ .Values.some_group }}" resources: - "{{ .Values.some_resource }}" + resourceNames: + - "{{ .Values.some_name }}" verbs: - "{{ .Values.some_verb }}" subjects: @@ -67,6 +69,8 @@ tests: - apps resources: - deployments + resourceNames: + - some-name verbs: - list - documentIndex: &roleBinding 3 diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 1de82eef..b08284bb 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 17.1.1 +version: 17.1.2 diff --git a/library/common/templates/lib/rbac/_rules.tpl b/library/common/templates/lib/rbac/_rules.tpl index be32dcc3..6f517e15 100644 --- a/library/common/templates/lib/rbac/_rules.tpl +++ b/library/common/templates/lib/rbac/_rules.tpl @@ -36,7 +36,17 @@ objectData: The object data to be used to render the RBAC. {{- fail "RBAC - Expected non-empty entry in [rbac.rules.resources]" -}} {{- end }} - {{ tpl . $rootCtx | quote }} - {{- end -}} + {{- end -}} + {{- /* resourceNames */}} + {{- if .resourceNames -}} + resourceNames: + {{- range .resourceNames -}} + {{- if not . -}} + {{- fail "RBAC - Expected non-empty entry in " -}} + {{- end }} + - {{ tpl . $rootCtx | quote }} + {{- end -}} + {{- end -}} {{- /* verbs */}} verbs: {{- range .verbs -}}