diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-08-24 13:29:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 13:29:20 -0400 |
commit | 361eb42619b2bccaf4fa7bb342dee779f72a512d (patch) | |
tree | 61769980b62ffaaaefa2636f419e829eeb56762c /pkg/env | |
parent | 2b05f4a0e6c05e4f653d86156858b4dff51a81b9 (diff) | |
parent | 65efcdf709a83e6d013b4e65247750c97236d89a (diff) | |
download | podman-361eb42619b2bccaf4fa7bb342dee779f72a512d.tar.gz podman-361eb42619b2bccaf4fa7bb342dee779f72a512d.tar.bz2 podman-361eb42619b2bccaf4fa7bb342dee779f72a512d.zip |
Merge pull request #15434 from rhatdan/manifest1
Allow podman to run in an environment with keys containing spaces
Diffstat (limited to 'pkg/env')
-rw-r--r-- | pkg/env/env.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/pkg/env/env.go b/pkg/env/env.go index 8af9fd77c..fb7949ad8 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -37,6 +37,22 @@ func Slice(m map[string]string) []string { return env } +// Map transforms the specified slice of environment variables into a +// map. +func Map(slice []string) map[string]string { + envmap := make(map[string]string, len(slice)) + for _, val := range slice { + data := strings.SplitN(val, "=", 2) + + if len(data) > 1 { + envmap[data[0]] = data[1] + } else { + envmap[data[0]] = "" + } + } + return envmap +} + // Join joins the two environment maps with override overriding base. func Join(base map[string]string, override map[string]string) map[string]string { if len(base) == 0 { @@ -87,10 +103,6 @@ func parseEnv(env map[string]string, line string) error { } // trim the front of a variable, but nothing else name := strings.TrimLeft(data[0], whiteSpaces) - if strings.ContainsAny(name, whiteSpaces) { - return fmt.Errorf("name %q has white spaces, poorly formatted name", name) - } - if len(data) > 1 { env[name] = data[1] } else { |