I'm trying to use a template to pull values from values.yaml, concatenate them into a CSV list. Here's an example of my solution.
values.yaml:
testValue1: "string1"
testValue2: "String2"
credentials:
- c1: "string3"
- c2: "string4"
_helpers.tpl:
{{- define "test.template" -}}
{{- $value1 := .Values.testValue1 -}}
{{- $value2 := .Values.testValue2 -}}
{{- $credentials := "" -}}
{{- range $index, $cred := .Values.credentials -}}
{{- $credentials = $cred "," $credentials -}}
{{- end -}}
{{- printf "%s,%s,%s" $value1 $value2 $credentials -}}
{{- end -}}
test.yaml
templatedValue: {{ template "test.template" }}
When I run helm template --output-dir outputs chart
I get:
test.yaml
templatedValue: %!s(<nil>),%!s(<nil>),
both the variables I set as values are nil, and the credentials
are just an empty string. If I put the values in the values.yaml directly into the test.yaml
file it works fine. So I'm not sure why I'm getting these nil values from the template. There's other templates in the _helpers.tpl
which grab values from the values.yaml file, so I'm not sure why my template doesn't work. Any help is greatly appreciated.
helm version:
Client: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
{{ template "test.template" }}
action executes"test.template"
but does not pass any parameters to it. So insidetest.template
the pipeline.Values
is invalid. – icza{{- define "chart.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}}
It has no parameters in it either eh? – roflcopter1101"chart.name"
called? I'm sure there are parameters passed to it when calling it. – icza{{ include "chart.name" . }}
. So should I do similar for mytest.template
template? – roflcopter1101.
if you have no other info what to pass, e.g.{{ template "test.template" . }}
. – icza