mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 17:07:04 +02:00
18 lines
592 B
Smarty
18 lines
592 B
Smarty
{{/*
|
|
Validate Role values
|
|
*/}}
|
|
{{- define "bjw-s.common.lib.rbac.role.validate" -}}
|
|
{{- $rootContext := .rootContext -}}
|
|
{{- $roleValues := .object -}}
|
|
{{- $type := required "The role needs to have an explicitly declared type" $roleValues.type -}}
|
|
{{- $typeList := list "Role" "ClusterRole" -}}
|
|
{{- $rules := $roleValues.rules -}}
|
|
|
|
{{- if not (mustHas $type $typeList) -}}
|
|
{{- fail (printf "\nYou selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
|
|
{{- end -}}
|
|
{{- if not $rules -}}
|
|
{{- fail "Rules can't be empty" -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|