diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-03-23 11:22:48 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-23 17:28:09 +0000 |
commit | 3f5da4d0dd04f755f9a46f93d59f2db58285436b (patch) | |
tree | a79aafb198dc2a6c2f93362fe8d724ce8cb5919b /libpod/container_internal.go | |
parent | f7c8dd5836002f3bf85a7bbe6c949cdece5194df (diff) | |
download | podman-3f5da4d0dd04f755f9a46f93d59f2db58285436b.tar.gz podman-3f5da4d0dd04f755f9a46f93d59f2db58285436b.tar.bz2 podman-3f5da4d0dd04f755f9a46f93d59f2db58285436b.zip |
Make container env variable conditional
Add only when it's not already present.
Add a more specific version in podman spec generation
so we get 'container=podman' not 'container=libpod'
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #540
Approved by: baude
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index d8002b000..28f7dfe45 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -909,7 +909,18 @@ func (c *Container) generateSpec() (*spec.Spec, error) { g.SetHostname(c.Hostname()) g.AddProcessEnv("HOSTNAME", g.Spec().Hostname) - g.AddProcessEnv("container", "libpod") + + // Only add container environment variable if not already present + foundContainerEnv := false + for _, env := range g.Spec().Process.Env { + if strings.HasPrefix(env, "container=") { + foundContainerEnv = true + break + } + } + if !foundContainerEnv { + g.AddProcessEnv("container", "libpod") + } return g.Spec(), nil } |