diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2019-07-11 13:39:31 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2019-07-11 17:15:20 -0400 |
commit | efe9c5b0e7968473b261eae4641e422e4a0f69a2 (patch) | |
tree | 275006e32102a428e0f2a53a244e71dbd8557f3a /cmd/podman/shared | |
parent | df75fc62c8316bce058bbdda29f66af9dcc5573a (diff) | |
download | podman-efe9c5b0e7968473b261eae4641e422e4a0f69a2.tar.gz podman-efe9c5b0e7968473b261eae4641e422e4a0f69a2.tar.bz2 podman-efe9c5b0e7968473b261eae4641e422e4a0f69a2.zip |
Add glob parsing for --env flag
Sometimes you want to add a few environmen variables based on the last field being a "*".
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/shared')
-rw-r--r-- | cmd/podman/shared/parse/parse.go | 19 |
1 files changed, 16 insertions, 3 deletions
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 } |