go-helm-client icon indicating copy to clipboard operation
go-helm-client copied to clipboard

Pass values to template action in addition yaml file

Open MatiasNMont opened this issue 2 years ago • 3 comments

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.

MatiasNMont avatar Jul 11 '22 00:07 MatiasNMont

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.

chaehni avatar Jul 12 '22 13:07 chaehni

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

MatiasNMont avatar Jul 12 '22 15:07 MatiasNMont

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.

chaehni avatar Jul 12 '22 15:07 chaehni