helm-charts/charts/library/common/templates/lib/chart/_getMapItemsWithKey.tpl
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 8bfc33eb8a
feat(common): Release v2.2.0 (#223)
2023-11-10 21:31:03 +01:00

17 lines
454 B
Smarty

{{/*
Returns the items in a map that have a certain key
*/}}
{{- define "bjw-s.common.lib.getMapItemsWithKey" -}}
{{- $map := .map -}}
{{- $keyToFind := .key -}}
{{- $output := dict -}}
{{- if not (empty $keyToFind) -}}
{{- range $key, $item := $map -}}
{{- if not (empty (dig $keyToFind nil $item)) -}}
{{- $_ := set $output $key $item -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $output | toYaml -}}
{{- end }}