feat(common): Release common 4.0.0 (#398)

Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
This commit is contained in:
Bernd Schorgers 2025-05-16 08:40:39 +02:00
parent 1e210f43e3
commit a01a89cb13
No known key found for this signature in database
327 changed files with 11181 additions and 7330 deletions

View file

@ -0,0 +1,23 @@
{{/*
Return the enabled RoleBindings.
*/}}
{{- define "bjw-s.common.lib.rbac.roleBinding.enabledRoleBindings" -}}
{{- $rootContext := .rootContext -}}
{{- $enabledRoleBindings := dict -}}
{{- range $name, $role := $rootContext.Values.rbac.bindings -}}
{{- if kindIs "map" $role -}}
{{- /* Enable Role by default, but allow override */ -}}
{{- $roleEnabled := true -}}
{{- if hasKey $role "enabled" -}}
{{- $roleEnabled = $role.enabled -}}
{{- end -}}
{{- if $roleEnabled -}}
{{- $_ := set $enabledRoleBindings $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledRoleBindings | toYaml -}}
{{- end -}}

View file

@ -4,9 +4,10 @@ Return a RoleBinding Object by its Identifier.
{{- define "bjw-s.common.lib.rbac.roleBinding.getByIdentifier" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $enabledRoleBindings := (include "bjw-s.common.lib.rbac.roleBinding.enabledRoleBindings" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- $roleBindingValues := dig $identifier nil $rootContext.Values.rbac.bindings -}}
{{- if not (empty $roleBindingValues) -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $roleBindingValues) -}}
{{- if (hasKey $enabledRoleBindings $identifier) -}}
{{- $objectValues := get $enabledRoleBindings $identifier -}}
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoleBindings)) -}}
{{- end -}}
{{- end -}}

View file

@ -1,32 +0,0 @@
{{/*
Validate RoleBinding values
*/}}
{{- define "bjw-s.common.lib.rbac.roleBinding.validate" -}}
{{- $rootContext := .rootContext -}}
{{- $roleBindingValues := .object -}}
{{- $type := required "The binding needs to have an explicitly declared type" $roleBindingValues.type -}}
{{- $typeList := list "RoleBinding" "ClusterRoleBinding" -}}
{{- $subjects := $roleBindingValues.subjects -}}
{{- $roleRef := required "A roleRef is required" $roleBindingValues.roleRef -}}
{{- if not (mustHas $type $typeList) -}}
{{- fail (printf "\nYou selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
{{- end -}}
{{- if not (hasKey $roleRef "identifier") -}}
{{- $name := required "If not using identifier roleRef must have a `name` key" $roleRef.name -}}
{{- $name := required "If not using identifier roleRef must have a `kind` key" $roleRef.kind -}}
{{- end -}}
{{- range $subject := $subjects -}}
{{- if not (hasKey . "identifier") -}}
{{- if not (hasKey . "name") -}}
{{- $name := required "If not using identifier a subject must have a `name` key" .name -}}
{{- else if not (hasKey . "namespace") -}}
{{- $namespace := required "If not using identifier a subject must have a `namespace` key" .namespace -}}
{{- else if not (hasKey . "kind") -}}
{{- $kind := required "If not using identifier a subject must have a `kind` key" .kind -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}