helm-charts/charts/library/common/templates/lib/role/_validate.tpl
Bernd Schorgers 90e6b9e7cf
feat(common): Release 3.5.0 (#357)
Co-authored-by: Lawrence Gil <lawrence.gil@assemblyglobal.com>
2024-10-04 13:50:55 +00:00

18 lines
590 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 "You 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 -}}