helm-charts/charts/library/common/templates/lib/controller/_enabled_containers.tpl
2023-09-13 11:24:23 +02:00

24 lines
766 B
Smarty

{{/*
Return the enabled containers for a controller.
*/}}
{{- define "bjw-s.common.lib.controller.enabledContainers" -}}
{{- $rootContext := .rootContext -}}
{{- $controllerObject := .controllerObject -}}
{{- $enabledContainers := dict -}}
{{- range $name, $container := $controllerObject.containers -}}
{{- if kindIs "map" $container -}}
{{- /* Enable container by default, but allow override */ -}}
{{- $containerEnabled := true -}}
{{- if hasKey $container "enabled" -}}
{{- $containerEnabled = $container.enabled -}}
{{- end -}}
{{- if $containerEnabled -}}
{{- $_ := set $enabledContainers $name . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $enabledContainers | toYaml -}}
{{- end -}}