template/interpolate: flip disable to enableenv

This commit is contained in:
Mitchell Hashimoto 2015-05-23 16:06:11 -07:00
parent 97a48e35bb
commit 47b570a2d2
3 changed files with 5 additions and 5 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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