diff --git a/components/engine/api/swagger.yaml b/components/engine/api/swagger.yaml index 746d815356..41016f18cd 100644 --- a/components/engine/api/swagger.yaml +++ b/components/engine/api/swagger.yaml @@ -754,7 +754,7 @@ definitions: default: false Env: description: | - A list of environment variables to set inside the container in the form `["VAR=value", ...]` + A list of environment variables to set inside the container in the form `["VAR=value", ...]`. A variable without `=` is removed from the environment, rather than to have an empty value. type: "array" items: type: "string" diff --git a/components/engine/container/env_test.go b/components/engine/container/env_test.go index fb304fe361..4ebf2640a8 100644 --- a/components/engine/container/env_test.go +++ b/components/engine/container/env_test.go @@ -4,11 +4,14 @@ import "testing" func TestReplaceAndAppendEnvVars(t *testing.T) { var ( - d = []string{"HOME=/"} - o = []string{"HOME=/root", "TERM=xterm"} + d = []string{"HOME=/", "FOO=foo_default"} + // remove FOO from env + // remove BAR from env (nop) + o = []string{"HOME=/root", "TERM=xterm", "FOO", "BAR"} ) env := ReplaceOrAppendEnvValues(d, o) + t.Logf("default=%v, override=%v, result=%v", d, o, env) if len(env) != 2 { t.Fatalf("expected len of 2 got %d", len(env)) }