Commit 47b570a2 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

template/interpolate: flip disable to enableenv

parent 97a48e35
......@@ -51,7 +51,7 @@ func Funcs(ctx *Context) template.FuncMap {
func funcGenEnv(ctx *Context) interface{} {
return func(k string) (string, error) {
if ctx.DisableEnv {
if !ctx.EnableEnv {
// The error message doesn't have to be that detailed since
// semantic checks should catch this.
return "", errors.New("env vars are not allowed here")
......
......@@ -26,7 +26,7 @@ func TestFuncEnv(t *testing.T) {
os.Setenv("PACKER_TEST_ENV", "foo")
defer os.Setenv("PACKER_TEST_ENV", "")
ctx := &Context{}
ctx := &Context{EnableEnv: true}
for _, tc := range cases {
i := &I{Value: tc.Input}
result, err := i.Render(ctx)
......@@ -53,7 +53,7 @@ func TestFuncEnv_disable(t *testing.T) {
},
}
ctx := &Context{DisableEnv: true}
ctx := &Context{EnableEnv: false}
for _, tc := range cases {
i := &I{Value: tc.Input}
result, err := i.Render(ctx)
......
......@@ -15,8 +15,8 @@ type Context struct {
// "user" function reads from.
UserVariables map[string]string
// DisableEnv disables the env function
DisableEnv bool
// EnableEnv enables the env function
EnableEnv bool
}
// I stands for "interpolation" and is the main interpolation struct
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment