'Creating yaml list using the go template
I am looking to create a yaml file in the following format. Using Go template
Custom_listeners:
Config1 : config_value
Config2 : config_value
copy_files:
- source_path: /path/to/file.txt
destination_path: /tmp/file.txt
I am using the follow template code to get the value
Template :
custom_listeners: {{ range $cl := $.Vars.CustomListeners }}
{{ range $k,$v := $cl.Values }}{{ $k }}: "{{ $v }}"
{{ end }}{{ end }}
Custom listener map :
type CustomListener map[string]interface{}
What changes can I made to above template to create the yaml in the follow format. with -
on the source_path:
Custom_listeners:
copy_files:
- source_path1: /path/to/file.txt
destination_path: /tmp/file.txt
- source_path2: /path/to/file.txt
destination_path: /tmp/file.txt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|