I’m implementing some go templates for Helmfile and I’m facing two issues:
{{ $name := Release.name }}
I need to render $name inside Values
I’m trying with:
{{ .Values.$name.something }}
but it doesn’t work, same for:
{{ .Values.{{$name}}.something }}
I need to have:
value: myurlone,myurltwo,myurlthree
I’m unclear on what you’re trying to do. It sounds like you’re parsing YAML and you want to render it into a different YAML schema with the text/template package. Is that right?
If not, can you restate your input and desired output?
P.S.: Also, it’s usually easier for us to read code snippets (especially those where whitespace is important, like YAML) when they are wrapped in backticks ( ` ) for example:
`inline code` becomes inline code
Or for multiple lines, put 3 backticks ( ``` ), then a new line, then your code, then a new line, and then another 3 back ticks. For example:
```
multiple
lines
of
code
```
becomes:
multiple
lines
of
code
This way we can see the actual YAML layout of the input (and output?) YAML.
Can you tell me why you’re trying to generate YAML with the text/template package instead of using a package specifically for dealing with YAML, such as the one I linked to (yaml package - gopkg.in/yaml.v2 - Go Packages)? How are you parsing the YAML in the first place to use it in the template?
Can you show an example of how you’re deserializing the input YAML? Knowing what form that is in will help answer your question about how to produce the output.