Consul-template: how to range value

Created on 10 May 2019  路  2Comments  路  Source: hashicorp/consul-template

I have some values in a k/v like:
one
two
three

can range each row?

question

Most helpful comment

This should do it:

{{- /* Given "key" = "one\ntwo\nthree" in consul KV */ -}}
{{- range $index, $value := (key "key" | split "\n") -}}
    {{- $value }}
{{ end -}}

All 2 comments

This should do it:

{{- /* Given "key" = "one\ntwo\nthree" in consul KV */ -}}
{{- range $index, $value := (key "key" | split "\n") -}}
    {{- $value }}
{{ end -}}

Thanks @sunnylua for using consul-template and a big thanks to @lite2073 for helping out.

In the future I suggest using our community support options as they are meant for helping answer questions where github issues are meant for bugs/feature-requests. You can find the community support links on the front page, but I'll repeat them here for convenience.

Community portal: https://discuss.hashicorp.com/c/consul
Other resources: https://www.consul.io/community.html

Thanks.

Was this page helpful?
0 / 5 - 0 ratings