summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-07-11 13:39:31 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2019-07-11 17:15:20 -0400
commitefe9c5b0e7968473b261eae4641e422e4a0f69a2 (patch)
tree275006e32102a428e0f2a53a244e71dbd8557f3a /cmd
parentdf75fc62c8316bce058bbdda29f66af9dcc5573a (diff)
downloadpodman-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')
-rw-r--r--cmd/podman/shared/parse/parse.go19
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
}