diff --git a/library/common/1.0.0/templates/lib/container/_env_from.tpl b/library/common/1.0.0/templates/lib/container/_env_from.tpl index 7e8d7504d0..ca2f1c6bd3 100644 --- a/library/common/1.0.0/templates/lib/container/_env_from.tpl +++ b/library/common/1.0.0/templates/lib/container/_env_from.tpl @@ -1,9 +1,5 @@ -{{/* -A custom dict is expected with envList and root. -It's designed to work for mainContainer AND initContainers. -Calling this from an initContainer, wouldn't work, as it would have a different "root" context, -and "tpl" on "$" would cause erors. -That's why the custom dict is expected. +{{/* Call this template like this: +{{- include "ix.v1.common.container.envFrom" (dict "envFrom" $envFrom "root" $root "containerName" $containerName) -}} */}} {{/* Environment Variables From included by the container */}} @@ -12,17 +8,22 @@ That's why the custom dict is expected. {{- $containerName := .containerName -}} {{- $root := .root -}} + {{- $envDict := (dict "envs" $envFrom) -}} + {{- if $envFrom -}} + {{- $envFrom = (fromYaml (tpl ($envDict | toYaml) $root)).envs -}} + {{- end -}} + {{- range $envFrom -}} {{- if and .secretRef .configMapRef -}} {{- fail "You can't define both secretRef and configMapRef on the same item." -}} {{- end -}} {{- if .secretRef }} - {{- $secretName := (tpl (required "Name is required for secretRef in envFrom." .secretRef.name) $root) }} + {{- $secretName := required "Name is required for secretRef in envFrom." .secretRef.name }} - secretRef: name: {{ $secretName | quote }} {{- include "ix.v1.common.util.storeEnvFromVarsForCheck" (dict "root" $root "containerName" $containerName "source" (printf "%s-%s" "secret" $secretName)) -}} {{- else if .configMapRef }} - {{- $configName := (tpl (required "Name is required for configMapRef in envFrom." .configMapRef.name) $root) }} + {{- $configName := required "Name is required for configMapRef in envFrom." .configMapRef.name }} - configMapRef: name: {{ $configName | quote }} {{- include "ix.v1.common.util.storeEnvFromVarsForCheck" (dict "root" $root "containerName" $containerName "source" (printf "%s-%s" "configmap" $configName)) -}} diff --git a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl index 79d2b98c22..69d14e2d88 100644 --- a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl +++ b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl @@ -106,17 +106,25 @@ {{- $root := .root -}} {{- $item := .item -}} {{- $name := .name -}} + + {{/* We need to make sure that is always dict. With nested values. + Will be removed once the tpl is moved in upper level + */}} + {{- $itemDict := (dict "item" $item) -}} + {{- if $item -}} + {{- $item = (fromYaml (tpl ($itemDict | toYaml) $root)).item -}} + {{- end -}} + {{- if not $item.mountPath -}} {{/* Make sure that we have a mountPath */}} {{- fail " must be defined, alternatively use the flag." -}} {{- end -}} - {{- $mountPath := (tpl $item.mountPath $root) -}} - {{- if not (hasPrefix "/" $mountPath) -}} - {{- fail (printf "Mount path (%s), must start with a forward slash -> / <-" $mountPath) -}} + {{- if not (hasPrefix "/" $item.mountPath) -}} + {{- fail (printf "Mount path (%s), must start with a forward slash -> / <-" $item.mountPath) -}} {{- end }} - name: {{ tpl $name $root }} - mountPath: {{ $mountPath }} + mountPath: {{ $item.mountPath }} {{- with $item.subPath }} - subPath: {{ tpl . $root }} + subPath: {{ . }} {{- end -}} {{- if (hasKey $item "readOnly") -}} {{- if or (eq $item.readOnly true) (eq $item.readOnly false) }} @@ -126,6 +134,6 @@ {{- end -}} {{- end -}} {{- with $item.mountPropagation }} - mountPropagation: {{ tpl . $root }} + mountPropagation: {{ . }} {{- end -}} {{- end -}}