my-apps/charts/common/templates/lib/pod/_nodeSelector.tpl
2025-08-24 00:09:37 +03:00

34 lines
993 B
Smarty

{{/* Returns Node Selector */}}
{{/* Call this template:
{{ include "tc.v1.common.lib.pod.nodeSelector" (dict "rootCtx" $ "objectData" $objectData) }}
rootCtx: The root context of the chart.
objectData: The object data to be used to render the Pod.
*/}}
{{- define "tc.v1.common.lib.pod.nodeSelector" -}}
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $selectors := dict -}}
{{/* Initialize from the "global" option */}}
{{- with $rootCtx.Values.podOptions.nodeSelector -}}
{{- $selectors = . -}}
{{- end -}}
{{/* Override with pods option */}}
{{- with $objectData.podSpec.nodeSelector -}}
{{- $selectors = . -}}
{{- end -}}
{{- if and (include "tc.v1.common.lib.util.stopAll" $rootCtx) (eq $objectData.type "DaemonSet") }}
"non-existing": "true"
{{ else }}
{{- range $k, $v := $selectors -}}
{{- if not $v -}}
{{- else }}
{{ $k }}: {{ tpl $v $rootCtx | quote }}
{{- end -}}
{{- end -}}
{{ end }}
{{- end -}}