Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(common/rbac): adds resourceNames field #1951

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions library/common-test/tests/rbac/data_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ tests:
- "{{ .Values.some_group }}"
resources:
- "{{ .Values.some_resource }}"
resourceNames:
- "{{ .Values.some_name }}"
verbs:
- "{{ .Values.some_verb }}"
subjects:
Expand Down Expand Up @@ -64,6 +66,8 @@ tests:
- apps
resources:
- deployments
resourceNames:
- some-name
verbs:
- list
- documentIndex: &roleBinding 3
Expand Down
19 changes: 19 additions & 0 deletions library/common-test/tests/rbac/validation_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,25 @@ tests:
- failedTemplate:
errorMessage: RBAC - Expected non-empty entry in <rbac.rules.resources>

- it: should fail with empty entry in resourceNames in rules in rbac
set:
rbac:
my-rbac:
enabled: true
primary: true
rules:
- apiGroups:
- ""
resources:
- pods
resourceNames:
- ""
verbs:
- get
asserts:
- failedTemplate:
errorMessage: RBAC - Expected non-empty entry in <rbac.rules.resourceNames>

- it: should fail with empty entry in verbs in rules in rbac
set:
rbac:
Expand Down
2 changes: 1 addition & 1 deletion library/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: common
description: A library chart for iX Official Catalog
type: library
version: 1.2.5
version: 1.2.6
appVersion: v1
annotations:
title: Common Library Chart
Expand Down
12 changes: 11 additions & 1 deletion library/common/templates/lib/rbac/_rules.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 <rbac.rules.resourceNames>" -}}
{{- end }}
- {{ tpl . $rootCtx | quote }}
{{- end -}}
{{- end -}}
{{- /* verbs */}}
verbs:
{{- range .verbs -}}
Expand Down
Loading