I have to check for mandatory values based on some condition.
My values.yaml is as below
id: 3
test:
id: 2
test1:
id: 1
In my template, I need to check if id is present at .Values.test.test1.id and assign that value. If not fall back to .Values.test.id and at last .Values.id. But id has to be mandatory and I need to use required function.
My template is as below
{{- if .Values.test.test1.id }}
<assign> {{ .Values.test.test1.id }}
{{- else }}
{{- $id := .Values.test.id }}
{{- $id2 := .Values.id }}
<assign> <need to check required with or of $id $id2> </assign>
{{- end }}
I know this can be solved with one elseif in between if and else. But I need to repeat the same logic for many ids.
What is the best way to achieve this?