From 33f733026befa13ba5c56ea0f84977253d36dd7a Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 22 Apr 2022 08:36:02 +0800 Subject: [PATCH] remove cmd.Env set Signed-off-by: yxxhero --- pkg/tmpl/context_funcs.go | 2 -- pkg/tmpl/context_funcs_test.go | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/pkg/tmpl/context_funcs.go b/pkg/tmpl/context_funcs.go index afd4f1c3..574be4d4 100644 --- a/pkg/tmpl/context_funcs.go +++ b/pkg/tmpl/context_funcs.go @@ -66,8 +66,6 @@ func (c *Context) Exec(command string, args []interface{}, inputs ...string) (st cmd := exec.Command(command, strArgs...) cmd.Dir = c.basePath - // inherit the environment variables from the parent process - cmd.Env = os.Environ() g := errgroup.Group{} diff --git a/pkg/tmpl/context_funcs_test.go b/pkg/tmpl/context_funcs_test.go index 41d05a35..83dd43d2 100644 --- a/pkg/tmpl/context_funcs_test.go +++ b/pkg/tmpl/context_funcs_test.go @@ -263,17 +263,7 @@ func TestExec(t *testing.T) { require.Nilf(t, err, "Expected no error to be returned when executing command") require.Equalf(t, expected, output, "Expected %s to be returned when executing command", expected) - // test inherited environment - expected = "bar\n" - os.Setenv("HELMFILE_TEST", "bar") - defer os.Unsetenv("HELMFILE_TEST") - output, err = ctx.Exec("bash", []interface{}{"-c", "echo $HELMFILE_TEST"}, "") - require.Nilf(t, err, "Expected no error to be returned when executing command") - require.Equalf(t, expected, output, "Expected %s to be returned when executing command", expected) - // test that the command is executed with no-zero exit code - _, err = ctx.Exec("bash", []interface{}{"-c", "exit 1"}, "") require.Error(t, err, "Expected error to be returned when executing command with non-zero exit code") - }