From 1921fad6f516a1d45e18054745eb1d2b03aaf665 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 8 Mar 2017 04:26:02 +0000 Subject: [PATCH] api: clarify that Env var without `=` is removed from the environment Signed-off-by: Akihiro Suda --- api/swagger.yaml | 2 +- container/env_test.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index 568379f29d..0516da7b45 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -741,7 +741,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/container/env_test.go b/container/env_test.go index fb304fe361..4ebf2640a8 100644 --- a/container/env_test.go +++ b/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)) }