Skip to content

Instantly share code, notes, and snippets.

@freehuntx
Created August 22, 2024 11:49
Show Gist options
  • Save freehuntx/e01a94e17eab1bb56da3978aa8180f1d to your computer and use it in GitHub Desktop.
Save freehuntx/e01a94e17eab1bb56da3978aa8180f1d to your computer and use it in GitHub Desktop.
Helm - Templated values
{{- define "templated-values" -}}
{{- $filteredValues := dict -}}
{{- range $key, $val := $.Values }}
{{- $isSubchart := false -}}
{{- range $name, $subchart := $.Subcharts }}
{{- if eq $key $name }}
{{- $isSubchart = true -}}
{{- end -}}
{{- end -}}
{{- if not $isSubchart }}
{{- $filteredValues = merge $filteredValues (dict $key $val) -}}
{{- end -}}
{{- end -}}
{{- tpl (toYaml $filteredValues) . -}}
{{- end }}
{{- $values := include "templated-values" . | fromYaml -}}
foo: {{ $values.val }}
foo: "Some text"
val: "{{ .Values.foo }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment