summaryrefslogtreecommitdiff
path: root/pkg/spec/containerconfig.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-04-15 13:39:22 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-05-01 10:16:23 -0400
commit869466eb25a41ab0e6daf9bc6ab951d7300d3f9d (patch)
tree9c0df02d0cb5fea29b6d38ec5199e7ffd9aa3484 /pkg/spec/containerconfig.go
parenteea77b5ae3e7fb8a60d438a79d3a4b30d35bb67c (diff)
downloadpodman-869466eb25a41ab0e6daf9bc6ab951d7300d3f9d.tar.gz
podman-869466eb25a41ab0e6daf9bc6ab951d7300d3f9d.tar.bz2
podman-869466eb25a41ab0e6daf9bc6ab951d7300d3f9d.zip
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>
Diffstat (limited to 'pkg/spec/containerconfig.go')
-rw-r--r--pkg/spec/containerconfig.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/spec/containerconfig.go b/pkg/spec/containerconfig.go
new file mode 100644
index 000000000..62108c012
--- /dev/null
+++ b/pkg/spec/containerconfig.go
@@ -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
+}