Created
August 22, 2024 11:49
-
-
Save freehuntx/e01a94e17eab1bb56da3978aa8180f1d to your computer and use it in GitHub Desktop.
Helm - Templated values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{- 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{- $values := include "templated-values" . | fromYaml -}} | |
foo: {{ $values.val }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo: "Some text" | |
val: "{{ .Values.foo }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment