summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate/oci.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-04-27 10:36:41 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-04-27 13:13:21 -0400
commit02671a103f7991a3c472f90d343a5979f3d3636a (patch)
tree4b5c8e29add304c8b3f327db7240703105ab4150 /pkg/specgen/generate/oci.go
parentca1c674d2e027b563c3e9fd92c335eb3f5e5e05d (diff)
downloadpodman-02671a103f7991a3c472f90d343a5979f3d3636a.tar.gz
podman-02671a103f7991a3c472f90d343a5979f3d3636a.tar.bz2
podman-02671a103f7991a3c472f90d343a5979f3d3636a.zip
Add support for volumes-from, image volumes, init
This should complete Podmanv2's support for volume-related flags. Most code was sourced from the old pkg/spec implementation with modifications to account for the split between frontend flags (volume, mount, tmpfs) and the backend flags implemented here. Also enables tests for podman run with volumes Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/specgen/generate/oci.go')
-rw-r--r--pkg/specgen/generate/oci.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index 8ca95016e..6b65ab10a 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -3,6 +3,7 @@ package generate
import (
"strings"
+ "github.com/containers/common/pkg/config"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/rootless"
@@ -48,7 +49,7 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) error {
return nil
}
-func SpecGenToOCI(s *specgen.SpecGenerator, rt *libpod.Runtime, newImage *image.Image) (*spec.Spec, error) {
+func SpecGenToOCI(s *specgen.SpecGenerator, rt *libpod.Runtime, rtc *config.Config, newImage *image.Image, mounts []spec.Mount) (*spec.Spec, error) {
var (
inUserNS bool
)
@@ -173,7 +174,17 @@ func SpecGenToOCI(s *specgen.SpecGenerator, rt *libpod.Runtime, newImage *image.
g.AddMount(cgroupMnt)
}
g.SetProcessCwd(s.WorkDir)
- g.SetProcessArgs(s.Command)
+ if s.Init {
+ initPath := s.InitPath
+ if initPath == "" && rtc != nil {
+ initPath = rtc.Engine.InitPath
+ }
+ cmd := []string{initPath, "--"}
+ cmd = append(cmd, s.Command...)
+ g.SetProcessArgs(cmd)
+ } else {
+ g.SetProcessArgs(s.Command)
+ }
g.SetProcessTerminal(s.Terminal)
for key, val := range s.Annotations {
@@ -227,7 +238,7 @@ func SpecGenToOCI(s *specgen.SpecGenerator, rt *libpod.Runtime, newImage *image.
}
// BIND MOUNTS
- configSpec.Mounts = SupercedeUserMounts(s.Mounts, configSpec.Mounts)
+ configSpec.Mounts = SupercedeUserMounts(mounts, configSpec.Mounts)
// Process mounts to ensure correct options
if err := InitFSMounts(configSpec.Mounts); err != nil {
return nil, err