helm-charts/charts/library/common/templates/lib/pod/fields/_containers.tpl
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 66389dec8b
feat(common): Release 2.0.1 (#193)
2023-10-03 09:24:41 +02:00

35 lines
1.7 KiB
Smarty

{{- /*
Returns the value for containers
*/ -}}
{{- define "bjw-s.common.lib.pod.field.containers" -}}
{{- $rootContext := .ctx.rootContext -}}
{{- $controllerObject := .ctx.controllerObject -}}
{{- /* Default to empty list */ -}}
{{- $orderedContainers := dict -}}
{{- $containers := list -}}
{{- /* Fetch configured containers for this controller */ -}}
{{- $enabledContainers := include "bjw-s.common.lib.controller.enabledContainers" (dict "rootContext" $rootContext "controllerObject" $controllerObject) | fromYaml }}
{{- range $key, $containerValues := $enabledContainers -}}
{{- /* Create object from the container values */ -}}
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $ "id" $key "values" $containerValues)) | fromYaml -}}
{{- /* Perform validations on the Container before rendering */ -}}
{{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "controllerObject" $controllerObject "containerObject" $containerObject) -}}
{{- /* Generate the Container spec */ -}}
{{- $renderedContainer := include "bjw-s.common.lib.container.spec" (dict "rootContext" $rootContext "controllerObject" $controllerObject "containerObject" $containerObject) | fromYaml -}}
{{- $containerOrder := (dig "order" 99 $containerValues) -}}
{{- $_ := set $orderedContainers (printf "%v-%s" $containerOrder $key) $renderedContainer -}}
{{- end -}}
{{- range $key, $containerValues := $orderedContainers -}}
{{- $containers = append $containers $containerValues -}}
{{- end -}}
{{- if not (empty $containers) -}}
{{- $containers | toYaml -}}
{{- end -}}
{{- end -}}