code review

This commit is contained in:
Donny Xia
2020-08-04 17:11:18 -07:00
parent c99bc47c8d
commit 2f7241f4c3
2 changed files with 4 additions and 4 deletions

View File

@@ -204,10 +204,11 @@ func (c *Filter) getCommand() (string, []string) {
return "docker", a return "docker", a
} }
var ignoreEnvKey []string = []string{"TMPDIR"}
// shouldEnvIgnored returns true if the environment variable key should be ignored // shouldEnvIgnored returns true if the environment variable key should be ignored
// by the container runtime. // by the container runtime.
func shouldEnvIgnored(envKey string) bool { func shouldEnvIgnored(envKey string) bool {
ignoreEnvKey := []string{"TMPDIR"}
for _, k := range ignoreEnvKey { for _, k := range ignoreEnvKey {
if k == envKey { if k == envKey {
return true return true

View File

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