go-helm-client
go-helm-client copied to clipboard
Pass values to template action in addition yaml file
Hi! I have a brief question. Are there some way to pass additional values to template action? i.e : I want to replicate command helm template <my-template> . --set value="myvalue".
If you use function func (helmclient.Client).TemplateChart(spec *helmclient.ChartSpec)
, Type *helmclient.ChartSpec doesn't include something as "values", It only include ValuesYaml.
I think the documentation for ChartSpec
is wrong. The ValuesYaml
field is not the values.yaml content. It's just an additional values file that you would normally set via -f
flag, i.e. template <my-template> . -f some_values.yaml
.
So what you can do in your case is setting the ValuesYaml
field to value: myvalue
. The rest of the default values will be taken from the actual values.yaml file contained in the chart.
I solved it doing string concatenation. It means, as ValuesYaml is a String I could concatenate my custom values to ValuesYml. However, I think it is not clean due to You need to consider indentation. In other side, If I need to set values such as --set myapp.mystruct.mykey=myvalue
, The approach I used become complicated
In that case suggest you use a struct to hold your values and use a Yaml marshaller to produce the corresponding yaml string. Then you don't need to worry about indentation.