From efe9c5b0e7968473b261eae4641e422e4a0f69a2 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 11 Jul 2019 13:39:31 -0400 Subject: 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 --- cmd/podman/shared/parse/parse.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'cmd/podman') 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 } -- cgit v1.2.3-54-g00ecf