github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/spec/containerconfig.go (about) 1 package createconfig 2 3 import ( 4 "github.com/containers/podman/v2/libpod" 5 "github.com/containers/podman/v2/libpod/define" 6 spec "github.com/opencontainers/runtime-spec/specs-go" 7 "github.com/pkg/errors" 8 "github.com/sirupsen/logrus" 9 ) 10 11 // MakeContainerConfig generates all configuration necessary to start a 12 // container with libpod from a completed CreateConfig struct. 13 func (config *CreateConfig) MakeContainerConfig(runtime *libpod.Runtime, pod *libpod.Pod) (*spec.Spec, []libpod.CtrCreateOption, error) { 14 if config.Pod != "" && pod == nil { 15 return nil, nil, errors.Wrapf(define.ErrInvalidArg, "pod was specified but no pod passed") 16 } else if config.Pod == "" && pod != nil { 17 return nil, nil, errors.Wrapf(define.ErrInvalidArg, "pod was given but no pod is specified") 18 } 19 20 // Parse volumes flag into OCI spec mounts and libpod Named Volumes. 21 // If there is an identical mount in the OCI spec, we will replace it 22 // with a mount generated here. 23 mounts, namedVolumes, err := config.parseVolumes(runtime) 24 if err != nil { 25 return nil, nil, err 26 } 27 28 runtimeSpec, err := config.createConfigToOCISpec(runtime, mounts) 29 if err != nil { 30 return nil, nil, err 31 } 32 33 options, err := config.getContainerCreateOptions(runtime, pod, mounts, namedVolumes) 34 if err != nil { 35 return nil, nil, err 36 } 37 38 logrus.Debugf("created OCI spec and options for new container") 39 40 return runtimeSpec, options, nil 41 }