kelseyhightower / confd

Manage local application configuration files using templates and data from etcd or consul
MIT License
8.36k stars 1.41k forks source link

Issue looping through an array of objects #868

Open C4F3Z1N opened 1 year ago

C4F3Z1N commented 1 year ago

I couldn't figure out which combination of functions and arguments I should use to loop through a file backend like this:

---
- ipv4: 192.168.192.99/32
  uuid: eabf31d2-3b00-43ab-83dd-11ebcc665977
  active: false

- ipv4: 192.168.192.180/32
  uuid: b03793b2-512b-4c06-9652-cc97c5b8cb8c
  active: true
...

My template file looks like this:

{{range lsdir "*"}}
    debug: {{.}}
{{end}}

I tried many combinations using the functions map, get, getvs, ls, lsdir, and the arguments "/*", "*", "/", but the error message remains the same:

line 2: cannot unmarshal !!seq into map[interface {}]interface {}

Any help is greatly appreciated.