Consul Template
The example covers:
- check on consul kv exist
- handling last kv entry
"person": [
{{if tree "/path/person"}}
{{range $index, $tree := tree "/path/person@dc-public"}}
{{if ne $index 0}},
{{end}}
{
"id" : "{{.Key}}" ,
"flag": "{{key_or_default (print "path/metadata/person/flag/" .Key) "false"}}"
}
{{end}}
{{end}}
]
"person": [
{
"id" : "p1" ,
"flag": "false"
}
,
{
"id" : "p2" ,
"flag": "true"
}
,
{
"id" : "p3" ,
"flag": "false"
}
]