我导出了一个变量:
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环境变量与值进行比较,并根据它们生成不同的结果输出文件?
答案 0 :(得分:0)
您需要先获取变量然后再进行比较。
例:
myproptmpl =
{{ if eq (getv .myparam) "one" }}
{{ "one" }}
{{ else }}
{{ "something else" }}
{{ end }}