Reputation: 463
I'm creating a configmap with required parameters. I wanted the error message given by helm to have the key name. So its easy to identify what was missed.
This is the part my template where i'm using the required function.
{{ $file_name }}.yml: |-
{{- range $key, $value := .Values.requiredParameters }}
{{ $key }}: {{ $value | required "missing a required parameter" }}
{{- end }}
I wanted the error message to look something like "$key is a required parameter". Is there a way to make it possible?
Upvotes: 2
Views: 2098
Reputation: 159040
required
is just an ordinary (template) function call taking an ordinary string parameter; it's not special syntax at all. Any way you could construct the string parameter would work.
For example, using the core printf
template function to construct the parameter:
{{ $key }}: {{ $value | required (printf "required parameter %s is missing" $key) }}
Upvotes: 1