summaryrefslogtreecommitdiff
path: root/cmd/podman/shared
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-03 01:02:57 +0200
committerGitHub <noreply@github.com>2020-04-03 01:02:57 +0200
commitccf0e0dd042d8a8d23dd0021ee267e7c9da9ff4a (patch)
treeee743630732dcad0828ef4880c3c706e50d62c18 /cmd/podman/shared
parentc3c6a7c8236fb43c3bc7172257b7fb15921e1668 (diff)
parent1f8569f7d768c411b5fed4446817c79b4b5337a0 (diff)
downloadpodman-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')
-rw-r--r--cmd/podman/shared/create.go27
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
+ }
}
}