0

我导出了一个变量:

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 环境变量与值进行比较,并根据它们从模板中生成不同的结果输出文件?

4

1 回答 1

0

您需要先获取变量,然后才能进行比较。

前任。:

myproptmpl =
{{ if eq (getv .myparam) "one" }}
    {{ "one" }}
{{ else }}
    {{ "something else" }}
{{ end }}
于 2016-08-26T14:36:40.877 回答