Remove redundant env field

This commit is contained in:
Donny Xia
2020-08-26 12:49:42 -07:00
parent 46194b3385
commit c202be0338
6 changed files with 40 additions and 46 deletions

View File

@@ -152,8 +152,6 @@ func (c *Filter) setupExec() {
c.Exec.Args = args
}
var tmpDirEnvKey string = "TMPDIR"
// getArgs returns the command + args to run to spawn the container
func (c *Filter) getCommand() (string, []string) {
// run the container using docker. this is simpler than using the docker
@@ -175,7 +173,7 @@ func (c *Filter) getCommand() (string, []string) {
args = append(args, "--mount", storageMount.String())
}
args = append(args, c.Env.GetDockerFlags()...)
args = append(args, runtimeutil.NewContainerEnvFromStringSlice(c.Env).GetDockerFlags()...)
a := append(args, c.Image)
return "docker", a
}

View File

@@ -6,7 +6,6 @@ package container
import (
"bytes"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
@@ -135,10 +134,11 @@ metadata:
t.FailNow()
}
tt.instance.Exec.FunctionConfig = cfg
tt.instance.Env.AddKeyValue("KYAML_TEST", "FOO")
tt.instance.Env = append(tt.instance.Env, "KYAML_TEST=FOO")
tt.instance.setupExec()
tt.expectedArgs = append(tt.expectedArgs, tt.instance.Env.GetDockerFlags()...)
tt.expectedArgs = append(tt.expectedArgs,
runtimeutil.NewContainerEnvFromStringSlice(tt.instance.Env).GetDockerFlags()...)
tt.expectedArgs = append(tt.expectedArgs, tt.instance.Image)
if !assert.Equal(t, "docker", tt.instance.Exec.Path) {
@@ -238,15 +238,3 @@ func TestFilter_ExitCode(t *testing.T) {
t.FailNow()
}
}
func TestIgnoreEnv(t *testing.T) {
os.Setenv(tmpDirEnvKey, "")
fltr := Filter{ContainerSpec: runtimeutil.ContainerSpec{Image: "example.com:version"}}
_, args := fltr.getCommand()
for _, arg := range args {
if arg == tmpDirEnvKey {
t.Fatalf("%s should not be exported to container", tmpDirEnvKey)
}
}
}