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

24 lines
627 B
Smarty

{{/* Return the name of the primary cnpg object */}}
{{- define "tc.v1.common.lib.util.cnpg.primary" -}}
{{- $cnpgs := .Values.cnpg -}}
{{- $enabledcnpges := dict -}}
{{- range $name, $cnpg := $cnpgs -}}
{{- if $cnpg.enabled -}}
{{- $_ := set $enabledcnpges $name . -}}
{{- end -}}
{{- end -}}
{{- $result := "" -}}
{{- range $name, $cnpg := $enabledcnpges -}}
{{- if and (hasKey $cnpg "primary") $cnpg.primary -}}
{{- $result = $name -}}
{{- end -}}
{{- end -}}
{{- if not $result -}}
{{- $result = keys $enabledcnpges | first -}}
{{- end -}}
{{- $result -}}
{{- end -}}