diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-12 10:33:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-12 10:33:18 +0200 |
commit | 6f3e7f7eccdfed03d3d617a9040d5e0b844ea637 (patch) | |
tree | 2632afdbee8c1f480ae515453161b65d89866d69 /cmd/podman | |
parent | 20f11718def2a5bf5af96363e9c7082ba48077f4 (diff) | |
parent | 369f8b8862e8918a011290311e44c1691f699c58 (diff) | |
download | podman-6f3e7f7eccdfed03d3d617a9040d5e0b844ea637.tar.gz podman-6f3e7f7eccdfed03d3d617a9040d5e0b844ea637.tar.bz2 podman-6f3e7f7eccdfed03d3d617a9040d5e0b844ea637.zip |
Merge pull request #3557 from rhatdan/env
Add support for --env-host
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/common.go | 3 | ||||
-rw-r--r-- | cmd/podman/shared/create.go | 10 | ||||
-rw-r--r-- | cmd/podman/shared/intermediate.go | 1 | ||||
-rw-r--r-- | cmd/podman/shared/parse/parse.go | 19 | ||||
-rw-r--r-- | cmd/podman/system_df.go | 2 |
5 files changed, 31 insertions, 4 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 50f3d9a7b..96a1c2244 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -221,6 +221,9 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "env", "e", []string{}, "Set environment variables in container", ) + createFlags.Bool( + "env-host", false, "Use all current host environment variables in container", + ) createFlags.StringSlice( "env-file", []string{}, "Read in a file of environment variables", diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 60a01ff6d..be1a731cc 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -482,6 +482,16 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. // ENVIRONMENT VARIABLES env := EnvVariablesFromData(data) + if c.Bool("env-host") { + for _, e := range os.Environ() { + pair := strings.SplitN(e, "=", 2) + if _, ok := env[pair[0]]; !ok { + if len(pair) > 1 { + env[pair[0]] = pair[1] + } + } + } + } if err := parse.ReadKVStrings(env, c.StringSlice("env-file"), c.StringArray("env")); err != nil { return nil, errors.Wrapf(err, "unable to process environment variables") } diff --git a/cmd/podman/shared/intermediate.go b/cmd/podman/shared/intermediate.go index eecd1604c..855f84086 100644 --- a/cmd/podman/shared/intermediate.go +++ b/cmd/podman/shared/intermediate.go @@ -393,6 +393,7 @@ func NewIntermediateLayer(c *cliconfig.PodmanCommand, remote bool) GenericCLIRes m["dns-search"] = newCRStringSlice(c, "dns-search") m["entrypoint"] = newCRString(c, "entrypoint") m["env"] = newCRStringArray(c, "env") + m["env-host"] = newCRBool(c, "env-host") m["env-file"] = newCRStringSlice(c, "env-file") m["expose"] = newCRStringSlice(c, "expose") m["gidmap"] = newCRStringSlice(c, "gidmap") diff --git a/cmd/podman/shared/parse/parse.go b/cmd/podman/shared/parse/parse.go index 7bc2652cb..a77002235 100644 --- a/cmd/podman/shared/parse/parse.go +++ b/cmd/podman/shared/parse/parse.go @@ -112,9 +112,22 @@ func parseEnv(env map[string]string, line string) error { if len(data) > 1 { env[name] = data[1] } else { - // if only a pass-through variable is given, clean it up. - val, _ := os.LookupEnv(name) - env[name] = val + if strings.HasSuffix(name, "*") { + name = strings.TrimSuffix(name, "*") + for _, e := range os.Environ() { + part := strings.SplitN(e, "=", 2) + if len(part) < 2 { + continue + } + if strings.HasPrefix(part[0], name) { + env[part[0]] = part[1] + } + } + } else { + // if only a pass-through variable is given, clean it up. + val, _ := os.LookupEnv(name) + env[name] = val + } } return nil } diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go index 85554bf05..5b5655dc9 100644 --- a/cmd/podman/system_df.go +++ b/cmd/podman/system_df.go @@ -546,7 +546,7 @@ func imagesVerboseOutput(ctx context.Context, metaData dfMetaData) error { "Created": "CREATED", "Size": "SIZE", "SharedSize": "SHARED SIZE", - "UniqueSize": "UNQUE SIZE", + "UniqueSize": "UNIQUE SIZE", "Containers": "CONTAINERS", } imagesVerboseDiskUsage, err := getImageVerboseDiskUsage(ctx, metaData.images, metaData.imagesUsedbyCtrMap) |