I have values.yml file that takes in a list of ports with this format and default values:
Ports:
- number: 443
protocol: http
The script that output the list of port to use as my input gives me this format:
port_list=$(./get_ports.sh)
output:
- 80
- 8080
I want the resulting rendered template to be
Ports:
- number: 80
- number: 8080
How would I accomplish this? I tried the following in my template file:
{{- with .Values.Ports }}
Ports:
{{- toYaml . | nindent 8 }}
{{- end }}
using helm template and setting values.Ports=$port_list, it ended up giving me a pipe and an extra dash like below, which I do not know where they come from, how do I accomplish getting to the format I want above based on the input?
Ports:
|-
- number: 80
- number: 8080
As a bonus, I would also like to have a default protocol in my port list when the protocol isn't specified.
Ports:
- number: 80
protocol: http
- number: 8080
protocol: http
Is there a clean way to do this with just templating?