Ignore TMPDIR when run container

This commit is contained in:
Donny Xia
2020-08-04 10:48:59 -07:00
parent c9e8631399
commit 60422c8090
2 changed files with 30 additions and 1 deletions

View File

@@ -210,3 +210,20 @@ func TestFilter_ExitCode(t *testing.T) {
t.FailNow()
}
}
func TestIgnoreEnv(t *testing.T) {
ignoredEnvKey := []string{"TMPDIR"}
for _, key := range ignoredEnvKey {
os.Setenv(key, "")
}
fltr := Filter{Image: "example.com:version"}
_, args := fltr.getCommand()
for _, arg := range args {
for _, key := range ignoredEnvKey {
if arg == key {
t.Fatalf("%s should not be exported to container", key)
}
}
}
}