summaryrefslogtreecommitdiff
path: root/cmd/podman/libpodruntime
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-09-13 12:16:14 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2018-09-13 12:16:14 -0400
commitecec1a5430885baf96d2e3d6153c7454c41a4617 (patch)
tree5d18f24541094d6a5f775ccb3bfee36ec606bf17 /cmd/podman/libpodruntime
parent61eda671eca96b6fa32369572d9b49850895d37b (diff)
downloadpodman-ecec1a5430885baf96d2e3d6153c7454c41a4617.tar.gz
podman-ecec1a5430885baf96d2e3d6153c7454c41a4617.tar.bz2
podman-ecec1a5430885baf96d2e3d6153c7454c41a4617.zip
Remove duplicate code between create.go and run.go
Create two new createInit for checking if the cotnainer is initialized correctly. createContainer which creates the actual container and containerConfig Also added libpodruntime.GetContainerRuntime to put common runtime code into separate function. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/libpodruntime')
-rw-r--r--cmd/podman/libpodruntime/runtime.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go
index b7281ed8c..be15d138d 100644
--- a/cmd/podman/libpodruntime/runtime.go
+++ b/cmd/podman/libpodruntime/runtime.go
@@ -7,6 +7,7 @@ import (
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/rootless"
+ "github.com/containers/libpod/pkg/util"
"github.com/containers/storage"
"github.com/pkg/errors"
"github.com/urfave/cli"
@@ -21,6 +22,21 @@ func GetRuntime(c *cli.Context) (*libpod.Runtime, error) {
return GetRuntimeWithStorageOpts(c, &storageOpts)
}
+// GetContainerRuntime generates a new libpod runtime configured by command line options for containers
+func GetContainerRuntime(c *cli.Context) (*libpod.Runtime, error) {
+ mappings, err := util.ParseIDMapping(c.StringSlice("uidmap"), c.StringSlice("gidmap"), c.String("subuidmap"), c.String("subgidmap"))
+ if err != nil {
+ return nil, err
+ }
+ storageOpts, err := GetDefaultStoreOptions()
+ if err != nil {
+ return nil, err
+ }
+ storageOpts.UIDMap = mappings.UIDMap
+ storageOpts.GIDMap = mappings.GIDMap
+ return GetRuntimeWithStorageOpts(c, &storageOpts)
+}
+
func GetRootlessStorageOpts() (storage.StoreOptions, error) {
var opts storage.StoreOptions