istio
1{{/*
2Complex logic ahead...
3We have three sets of values, in order of precedence (last wins):
41. The builtin values.yaml defaults
52. The profile the user selects
63. Users input (-f or --set)
7
8Unfortunately, Helm provides us (1) and (3) together (as .Values), making it hard to insert (2).
9
10However, we can workaround this by placing all of (1) under a specific key (.Values.defaults).
11We can then merge the profile onto the defaults, then the user settings onto that.
12Finally, we can set all of that under .Values so the chart behaves without awareness.
13*/}}
14{{- $defaults := $.Values.defaults }}
15{{- $_ := unset $.Values "defaults" }}
16{{- $profile := dict }}
17{{- with .Values.profile }}
18{{- with $.Files.Get (printf "files/profile-%s.yaml" .)}}
19{{- $profile = (. | fromYaml) }}
20{{- else }}
21{{ fail (cat "unknown profile" $.Values.profile) }}
22{{- end }}
23{{- end }}
24{{- with .Values.compatibilityVersion }}
25{{- with $.Files.Get (printf "files/profile-compatibility-version-%s.yaml" .) }}
26{{- $ignore := mustMergeOverwrite $profile (. | fromYaml) }}
27{{- else }}
28{{ fail (cat "unknown compatibility version" $.Values.compatibilityVersion) }}
29{{- end }}
30{{- end }}
31{{- if $profile }}
32{{- $a := mustMergeOverwrite $defaults $profile }}
33{{- end }}
34{{- $b := set $ "Values" (mustMergeOverwrite $defaults $.Values) }}
35