Search code examples
timezonekubernetes-helmreact-helmet

I need to validate a timezone set in Values.yaml


I have a Helm template that uses Values.timezone value to set an environment variable, like below:

... env: ...

  • name: "timezone" value: {{ Values.timezone | Default "EST" }}

I need to validate the timezone set in Values file following the IANA Timezone Database. If an invalid one is set, I use a default instead so the pod is created with a valid one.


Solution

  • helm includes functions of the sprig library to enhance the templating functions and pipeline. you can use those functions in your templates to do stuff, like validating a string or date.

    I'd suggest you checkout either the regex or date functions to figure out how to check for the validity of the value.

    You could also apply a json schema file to validate the values of your helm chart. This would be cleaner bcs you wouldn't have to write any templating logic to do so and a schema validation would actually prevent a faulty configured installation.