mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
api: clarify that Env var without =
is removed from the environment
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
parent
193730bec1
commit
1921fad6f5
2 changed files with 6 additions and 3 deletions
|
@ -741,7 +741,7 @@ definitions:
|
||||||
default: false
|
default: false
|
||||||
Env:
|
Env:
|
||||||
description: |
|
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"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
|
|
@ -4,11 +4,14 @@ import "testing"
|
||||||
|
|
||||||
func TestReplaceAndAppendEnvVars(t *testing.T) {
|
func TestReplaceAndAppendEnvVars(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
d = []string{"HOME=/"}
|
d = []string{"HOME=/", "FOO=foo_default"}
|
||||||
o = []string{"HOME=/root", "TERM=xterm"}
|
// remove FOO from env
|
||||||
|
// remove BAR from env (nop)
|
||||||
|
o = []string{"HOME=/root", "TERM=xterm", "FOO", "BAR"}
|
||||||
)
|
)
|
||||||
|
|
||||||
env := ReplaceOrAppendEnvValues(d, o)
|
env := ReplaceOrAppendEnvValues(d, o)
|
||||||
|
t.Logf("default=%v, override=%v, result=%v", d, o, env)
|
||||||
if len(env) != 2 {
|
if len(env) != 2 {
|
||||||
t.Fatalf("expected len of 2 got %d", len(env))
|
t.Fatalf("expected len of 2 got %d", len(env))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue