From 47b570a2d2510e007afeb222c6724fe161540b96 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 23 May 2015 16:06:11 -0700 Subject: [PATCH] template/interpolate: flip disable to enableenv --- template/interpolate/funcs.go | 2 +- template/interpolate/funcs_test.go | 4 ++-- template/interpolate/i.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/template/interpolate/funcs.go b/template/interpolate/funcs.go index 68592e046..1ddbbe167 100644 --- a/template/interpolate/funcs.go +++ b/template/interpolate/funcs.go @@ -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") diff --git a/template/interpolate/funcs_test.go b/template/interpolate/funcs_test.go index 7afa53447..aad05d376 100644 --- a/template/interpolate/funcs_test.go +++ b/template/interpolate/funcs_test.go @@ -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) diff --git a/template/interpolate/i.go b/template/interpolate/i.go index 1033ad86a..5f70ed82a 100644 --- a/template/interpolate/i.go +++ b/template/interpolate/i.go @@ -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