Browse code

Merge pull request #31634 from AkihiroSuda/clarify-env-without-value

api: clarify that Env var without `=` is removed from the environment

Vincent Demeester authored on 2017/04/01 00:34:32
Showing 2 changed files
... ...
@@ -754,7 +754,7 @@ definitions:
754 754
         default: false
755 755
       Env:
756 756
         description: |
757
-          A list of environment variables to set inside the container in the form `["VAR=value", ...]`
757
+          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.
758 758
         type: "array"
759 759
         items:
760 760
           type: "string"
... ...
@@ -4,11 +4,14 @@ import "testing"
4 4
 
5 5
 func TestReplaceAndAppendEnvVars(t *testing.T) {
6 6
 	var (
7
-		d = []string{"HOME=/"}
8
-		o = []string{"HOME=/root", "TERM=xterm"}
7
+		d = []string{"HOME=/", "FOO=foo_default"}
8
+		// remove FOO from env
9
+		// remove BAR from env (nop)
10
+		o = []string{"HOME=/root", "TERM=xterm", "FOO", "BAR"}
9 11
 	)
10 12
 
11 13
 	env := ReplaceOrAppendEnvValues(d, o)
14
+	t.Logf("default=%v, override=%v, result=%v", d, o, env)
12 15
 	if len(env) != 2 {
13 16
 		t.Fatalf("expected len of 2 got %d", len(env))
14 17
 	}