diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-05-07 21:44:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-07 21:44:47 +0200 |
commit | ab518cdba02b85a32d3c2bce4c0b65dcdea4dfcc (patch) | |
tree | 916c768fca45b5e809f9e941b5425e760dcfe08c /pkg/specgen | |
parent | 1d3cdf9a4642df073becb54d178d6b1959526a47 (diff) | |
parent | 99bdafba999078bb5763c65cf7dfe7df520030f7 (diff) | |
download | podman-ab518cdba02b85a32d3c2bce4c0b65dcdea4dfcc.tar.gz podman-ab518cdba02b85a32d3c2bce4c0b65dcdea4dfcc.tar.bz2 podman-ab518cdba02b85a32d3c2bce4c0b65dcdea4dfcc.zip |
Merge pull request #6115 from rhatdan/env
podman: split env variables in env and overrides
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/container.go | 29 | ||||
-rw-r--r-- | pkg/specgen/specgen.go | 1 |
2 files changed, 18 insertions, 12 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go index 92a2b4d35..e4bd2991a 100644 --- a/pkg/specgen/generate/container.go +++ b/pkg/specgen/generate/container.go @@ -9,6 +9,7 @@ import ( envLib "github.com/containers/libpod/pkg/env" "github.com/containers/libpod/pkg/signal" "github.com/containers/libpod/pkg/specgen" + "github.com/pkg/errors" "golang.org/x/sys/unix" ) @@ -48,24 +49,28 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat s.StopSignal = &sig } + rtc, err := r.GetConfig() + if err != nil { + return err + } + // Get Default Environment + defaultEnvs, err := envLib.ParseSlice(rtc.Containers.Env) + if err != nil { + return errors.Wrap(err, "Env fields in containers.conf failed to parse") + } + // Image envs from the image if they don't exist - // already - env, err := newImage.Env(ctx) + // already, overriding the default environments + imageEnvs, err := newImage.Env(ctx) if err != nil { return err } - if len(env) > 0 { - envs, err := envLib.ParseSlice(env) - if err != nil { - return err - } - for k, v := range envs { - if _, exists := s.Env[k]; !exists { - s.Env[v] = k - } - } + envs, err := envLib.ParseSlice(imageEnvs) + if err != nil { + return errors.Wrap(err, "Env fields from image failed to parse") } + s.Env = envLib.Join(envLib.Join(defaultEnvs, envs), s.Env) labels, err := newImage.Labels(ctx) if err != nil { diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go index 4ad6dd6fb..bb01a5d14 100644 --- a/pkg/specgen/specgen.go +++ b/pkg/specgen/specgen.go @@ -47,6 +47,7 @@ type ContainerBasicConfig struct { // Optional. Env map[string]string `json:"env,omitempty"` // Terminal is whether the container will create a PTY. + // Optional. Terminal bool `json:"terminal,omitempty"` // Stdin is whether the container will keep its STDIN open. Stdin bool `json:"stdin,omitempty"` |