simple consul-template syntax question

484 views
Skip to first unread message

Jay Christopherson

unread,
May 16, 2016, 2:02:09 PM5/16/16
to Consul
I'm working on consul-template for the first time.  I'm trying to do a simple test for existence, before fetching a value from Vault.  I've already validated that I can't fetch the value from Vault, but consul-template doesn't seem to like my conditional:

FOO_VALUE {{ if isset .ENV.FOO }} {{ .ENV.FOO }} {{ else }} {{ with secret "secret/stuff"}}{{.Data.FOO }}{{ end }}

But when I try to run it, I get this error:


Consul Template returned errors:
template: template: test.tmpl:1: function "isset" not defined

I thought the documentation for consul-template indicates that templates are in Go Template format and I pulled "isset" right out of the primer for conditionals in the Go Template documentation. 

Am I missing something?  

Jay Christopherson

unread,
May 16, 2016, 2:45:16 PM5/16/16
to Consul
Ok, so not all Go libs are exported to templates.  That's fine.  I got this to work:

{{ if env "FOO" }}{{ env "FOO" }}{{ else }}{{ with secret "secret/stuff"}}{{.Data.FOO }}{{ end }}{{ end }}


Reply all
Reply to author
Forward
0 new messages