diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-02-19 15:55:14 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-03-03 11:47:24 +0100 |
commit | ad8e0e5e49a96146d52cfa41945afbe973ba30af (patch) | |
tree | 0ac13e0869ade22faf212a0cf2602ac832d90820 /pkg/adapter/pods.go | |
parent | 1641ee61802ad5e13a9ddf0a20099fe31f73768d (diff) | |
download | podman-ad8e0e5e49a96146d52cfa41945afbe973ba30af.tar.gz podman-ad8e0e5e49a96146d52cfa41945afbe973ba30af.tar.bz2 podman-ad8e0e5e49a96146d52cfa41945afbe973ba30af.zip |
consolidate env handling into pkg/env
Env-variable related code is scattered across several packages making it
hard to maintain and extend. Consolidate the code into a new pkg/env
package.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/adapter/pods.go')
-rw-r--r-- | pkg/adapter/pods.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index 0d9fa7210..dc856cc8d 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -22,6 +22,7 @@ import ( "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/pkg/adapter/shortcuts" ann "github.com/containers/libpod/pkg/annotations" + envLib "github.com/containers/libpod/pkg/env" ns "github.com/containers/libpod/pkg/namespaces" createconfig "github.com/containers/libpod/pkg/spec" "github.com/containers/libpod/pkg/util" @@ -916,9 +917,6 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container containerConfig.User = userConfig containerConfig.Security = securityConfig - // Set default environment variables and incorporate data from image, if necessary - envs := shared.EnvVariablesFromData(imageData) - annotations := make(map[string]string) if infraID != "" { annotations[ann.SandboxID] = infraID @@ -927,6 +925,14 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container containerConfig.Annotations = annotations // Environment Variables + envs := map[string]string{} + if imageData != nil { + imageEnv, err := envLib.ParseSlice(imageData.Config.Env) + if err != nil { + return nil, errors.Wrap(err, "error parsing image environment variables") + } + envs = imageEnv + } for _, e := range containerYAML.Env { envs[e.Name] = e.Value } |