Add a new function for converting a CreateConfig

Right now, there are two major API calls necessary to turn a
filled-in CreateConfig into the options and OCI spec necessary to
make a libpod Container. I'm intending on refactoring both of
these extensively to unify a few things, so make a common
frontend to both that will prevent API changes from leaking out
of the package.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
Matthew Heon
2019-04-15 13:39:22 -04:00
parent eea77b5ae3
commit 869466eb25
4 changed files with 25 additions and 8 deletions

View File

@ -0,0 +1,22 @@
package createconfig
import (
"github.com/containers/libpod/libpod"
spec "github.com/opencontainers/runtime-spec/specs-go"
)
// MakeContainerConfig generates all configuration necessary to start a
// container with libpod from a completed CreateConfig struct.
func (config *CreateConfig) MakeContainerConfig(runtime *libpod.Runtime, pod *libpod.Pod) (*spec.Spec, []libpod.CtrCreateOption, error) {
runtimeSpec, err := config.createConfigToOCISpec()
if err != nil {
return nil, nil, err
}
options, err := config.getContainerCreateOptions(runtime, pod)
if err != nil {
return nil, nil, err
}
return runtimeSpec, options, nil
}