How to neatly define an if conditional operation for a list of values in Helm template?

11/6/2019

There are, let's say, 10 environments (a-j) and I want a condition to be executed for (a-e) as done below in the Helm template:

{{- if or (eq .Values.env "env-a") (eq .Values.env "env-b") (eq .Values.env "env-c") (eq .Values.env "env-d") (eq .Values.env "env-e")}}

Now, instead of repeating the eq block so many times, is there a better way to achieve this? Thanks.

-- L P
kubernetes
kubernetes-helm
yaml

1 Answer

11/7/2019

No, there is no better way. You can check all available Helm Chart operators here.

-- RafaƂ Leszko
Source: StackOverflow