我导出了一个变量:
export myparam=one我有模板: file.tmpl:
myproptmpl =
{{ if eq .myparam "one" }}
{{ "one" }}
{{ else }}
{{ "something else" }}
{{ end }}当我运行confd时,我得到:
# /usr/bin/confd -onetime -backend env
2016-04-20T15:21:58Z 8faae31d53a1 /usr/bin/confd[91]: ERROR template: file.tmpl:70:6: executing "file.tmpl" at <eq .myparam "one">: error calling eq: invalid type for comparison我是confd上的新手。如何将OS环境变量与值进行比较,并根据它们从模板中生成不同的输出文件?
发布于 2016-08-26 22:36:41
你需要先获取变量,然后再进行比较。
示例:
myproptmpl =
{{ if eq (getv .myparam) "one" }}
{{ "one" }}
{{ else }}
{{ "something else" }}
{{ end }}https://stackoverflow.com/questions/36748423
复制相似问题