Using the ‘required’ function

Go provides a way for setting template options to control behaviorwhen a map is indexed with a key that’s not present in the map. Thisis typically set with template.Options(“missingkey=option”), where optioncan be default, zero, or error. While setting this option to error willstop execution with an error, this would apply to every missing key in themap. There may be situations where a chart developer wants to enforce thisbehavior for select values in the values.yml file.

The required function gives developers the ability to declare a value entryas required for template rendering. If the entry is empty in values.yml, thetemplate will not render and will return an error message supplied by thedeveloper.

For example:

  1. {{ required "A valid foo is required!" .Values.foo }}

The above will render the template when .Values.foo is defined, but will failto render and exit when .Values.foo is undefined.