diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-03 01:02:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-03 01:02:57 +0200 |
commit | ccf0e0dd042d8a8d23dd0021ee267e7c9da9ff4a (patch) | |
tree | ee743630732dcad0828ef4880c3c706e50d62c18 /cmd/podman/shared/create.go | |
parent | c3c6a7c8236fb43c3bc7172257b7fb15921e1668 (diff) | |
parent | 1f8569f7d768c411b5fed4446817c79b4b5337a0 (diff) | |
download | podman-ccf0e0dd042d8a8d23dd0021ee267e7c9da9ff4a.tar.gz podman-ccf0e0dd042d8a8d23dd0021ee267e7c9da9ff4a.tar.bz2 podman-ccf0e0dd042d8a8d23dd0021ee267e7c9da9ff4a.zip |
Merge pull request #5696 from rhatdan/cc
Fix environment handling from containers.conf
Diffstat (limited to 'cmd/podman/shared/create.go')
-rw-r--r-- | cmd/podman/shared/create.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 5fa8d6c0b..68a36d967 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -538,14 +538,16 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. } } - // env overrides any previous variables - cmdlineEnv := c.StringSlice("env") - if len(cmdlineEnv) > 0 { - parsedEnv, err := envLib.ParseSlice(cmdlineEnv) - if err != nil { - return nil, err + if c.IsSet("env") { + // env overrides any previous variables + cmdlineEnv := c.StringSlice("env") + if len(cmdlineEnv) > 0 { + parsedEnv, err := envLib.ParseSlice(cmdlineEnv) + if err != nil { + return nil, err + } + env = envLib.Join(env, parsedEnv) } - env = envLib.Join(env, parsedEnv) } // LABEL VARIABLES @@ -636,10 +638,13 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. if err != nil { return nil, errors.Wrapf(err, "unable to translate --shm-size") } - // Verify the additional hosts are in correct format - for _, host := range c.StringSlice("add-host") { - if _, err := parse.ValidateExtraHost(host); err != nil { - return nil, err + + if c.IsSet("add-host") { + // Verify the additional hosts are in correct format + for _, host := range c.StringSlice("add-host") { + if _, err := parse.ValidateExtraHost(host); err != nil { + return nil, err + } } } |