summaryrefslogtreecommitdiff
path: root/pkg/specgen
diff options
context:
space:
mode:
authorcdoern <cbdoer23@g.holycross.edu>2022-04-28 22:37:11 -0400
committerMatthew Heon <matthew.heon@pm.me>2022-05-05 16:02:00 -0400
commita8b55a3b9f8f2395d0d8ac3a4112fb3ff30da630 (patch)
tree9278e03278b954bef7e71a80bd38acbecba09e1e /pkg/specgen
parentb2025c64f43e74c84fb928f07df7bab3f776fe2d (diff)
downloadpodman-a8b55a3b9f8f2395d0d8ac3a4112fb3ff30da630.tar.gz
podman-a8b55a3b9f8f2395d0d8ac3a4112fb3ff30da630.tar.bz2
podman-a8b55a3b9f8f2395d0d8ac3a4112fb3ff30da630.zip
pass networks to container clone
since the network config is a string map, json.unmarshal does not recognize the config and spec as the same entity, need to map this option manually resolves #13713 Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Diffstat (limited to 'pkg/specgen')
-rw-r--r--pkg/specgen/generate/container.go2
-rw-r--r--pkg/specgen/generate/container_create.go16
2 files changed, 11 insertions, 7 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index 831c1d7b9..63caaa77c 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -501,6 +501,8 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
_, mounts := c.SortUserVolumes(c.Spec())
specg.Mounts = mounts
specg.HostDeviceList = conf.DeviceHostSrc
+ specg.Networks = conf.Networks
+
mapSecurityConfig(conf, specg)
if c.IsInfra() { // if we are creating this spec for a pod's infra ctr, map the compatible options
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index 8b9ed8ffe..19a2b702c 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -175,13 +175,15 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
return nil, nil, nil, errors.New("the given container could not be retrieved")
}
conf := c.Config()
- out, err := json.Marshal(conf.Spec.Linux)
- if err != nil {
- return nil, nil, nil, err
- }
- err = json.Unmarshal(out, runtimeSpec.Linux)
- if err != nil {
- return nil, nil, nil, err
+ if conf != nil && conf.Spec != nil && conf.Spec.Linux != nil {
+ out, err := json.Marshal(conf.Spec.Linux)
+ if err != nil {
+ return nil, nil, nil, err
+ }
+ err = json.Unmarshal(out, runtimeSpec.Linux)
+ if err != nil {
+ return nil, nil, nil, err
+ }
}
if s.ResourceLimits != nil {
switch {