mirror of
https://github.com/truenas/charts.git
synced 2026-04-27 12:03:03 +08:00
20 lines
601 B
Smarty
20 lines
601 B
Smarty
{{/*
|
|
Checks if a list of keys are present in a dictionary
|
|
*/}}
|
|
{{- define "common.schema.validateKeys" -}}
|
|
{{- $values := . -}}
|
|
{{- if and (hasKey $values "values") (hasKey $values "checkKeys") -}}
|
|
{{- $missingKeys := list -}}
|
|
{{- range $values.checkKeys -}}
|
|
{{- if eq (hasKey $values.values . ) false -}}
|
|
{{- $missingKeys = mustAppend $missingKeys . -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- if $missingKeys -}}
|
|
{{- fail (printf "Missing %s from dictionary" ($missingKeys | join ", ")) -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{- fail "A dictionary and list of keys to check must be provided" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|