diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-03 14:18:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-03 14:18:28 +0100 |
commit | 34baea814ba6af58e7f7b65622fd0fb7b838fbf7 (patch) | |
tree | 0ac13e0869ade22faf212a0cf2602ac832d90820 /pkg/adapter/containers.go | |
parent | 1641ee61802ad5e13a9ddf0a20099fe31f73768d (diff) | |
parent | ad8e0e5e49a96146d52cfa41945afbe973ba30af (diff) | |
download | podman-34baea814ba6af58e7f7b65622fd0fb7b838fbf7.tar.gz podman-34baea814ba6af58e7f7b65622fd0fb7b838fbf7.tar.bz2 podman-34baea814ba6af58e7f7b65622fd0fb7b838fbf7.zip |
Merge pull request #5367 from vrothberg/ENVFIX
consolidate env handling into pkg/env
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r-- | pkg/adapter/containers.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 08e19edb8..a5e668b04 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -19,13 +19,13 @@ import ( "github.com/containers/image/v5/manifest" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/shared" - "github.com/containers/libpod/cmd/podman/shared/parse" "github.com/containers/libpod/libpod" "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/events" "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/libpod/logs" "github.com/containers/libpod/pkg/adapter/shortcuts" + envLib "github.com/containers/libpod/pkg/env" "github.com/containers/libpod/pkg/systemd/generate" "github.com/containers/storage" "github.com/pkg/errors" @@ -987,9 +987,20 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal // Validate given environment variables env := map[string]string{} - if err := parse.ReadKVStrings(env, cli.EnvFile, cli.Env); err != nil { - return ec, errors.Wrapf(err, "unable to process environment variables") + if len(cli.EnvFile) > 0 { + for _, f := range cli.EnvFile { + fileEnv, err := envLib.ParseFile(f) + if err != nil { + return ec, err + } + env = envLib.Join(env, fileEnv) + } + } + cliEnv, err := envLib.ParseSlice(cli.Env) + if err != nil { + return ec, errors.Wrap(err, "error parsing environment variables") } + env = envLib.Join(env, cliEnv) streams := new(libpod.AttachStreams) streams.OutputStream = os.Stdout |