summaryrefslogtreecommitdiff
path: root/pkg/specgen
diff options
context:
space:
mode:
authorCharlie Doern <cdoern@redhat.com>2022-08-22 14:25:10 -0400
committerCharlie Doern <cdoern@redhat.com>2022-08-22 14:27:42 -0400
commit53369aaa1575caa652461d3671713577fa0ac291 (patch)
treea01f400f5303871bcd39f6b36c4e401643c88bac /pkg/specgen
parentaefd0aed3990848e77b706d673c23108092594a0 (diff)
downloadpodman-53369aaa1575caa652461d3671713577fa0ac291.tar.gz
podman-53369aaa1575caa652461d3671713577fa0ac291.tar.bz2
podman-53369aaa1575caa652461d3671713577fa0ac291.zip
pass environment variables to container clone
the env vars are held in the spec rather than the config, so they need to be mapped manually. They are also of a different format so special handling needed to be added. All env from the parent container will now be passed to the clone. resolves #15242 Signed-off-by: Charlie Doern <cdoern@redhat.com>
Diffstat (limited to 'pkg/specgen')
-rw-r--r--pkg/specgen/generate/container.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index ec85f0f79..85cd8f5ca 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -347,9 +347,21 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
conf.Systemd = tmpSystemd
conf.Mounts = tmpMounts
- if conf.Spec != nil && conf.Spec.Linux != nil && conf.Spec.Linux.Resources != nil {
- if specg.ResourceLimits == nil {
- specg.ResourceLimits = conf.Spec.Linux.Resources
+ if conf.Spec != nil {
+ if conf.Spec.Linux != nil && conf.Spec.Linux.Resources != nil {
+ if specg.ResourceLimits == nil {
+ specg.ResourceLimits = conf.Spec.Linux.Resources
+ }
+ }
+ if conf.Spec.Process != nil && conf.Spec.Process.Env != nil {
+ env := make(map[string]string)
+ for _, entry := range conf.Spec.Process.Env {
+ split := strings.Split(entry, "=")
+ if len(split) == 2 {
+ env[split[0]] = split[1]
+ }
+ }
+ specg.Env = env
}
}