diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-09-14 16:56:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-14 16:56:34 -0400 |
commit | 8b21e2ecf5b0ffd81c35dc8a3831bf99585695be (patch) | |
tree | ae4de56be2281aa298ded4685cf5e20d136fa124 /cmd/podman/libpodruntime/runtime.go | |
parent | 77985bc25bde30bb8e4ed6abab02242bbb5c0612 (diff) | |
parent | ecec1a5430885baf96d2e3d6153c7454c41a4617 (diff) | |
download | podman-8b21e2ecf5b0ffd81c35dc8a3831bf99585695be.tar.gz podman-8b21e2ecf5b0ffd81c35dc8a3831bf99585695be.tar.bz2 podman-8b21e2ecf5b0ffd81c35dc8a3831bf99585695be.zip |
Merge pull request #1461 from rhatdan/run
Remove duplicate code between create.go and run.go
Diffstat (limited to 'cmd/podman/libpodruntime/runtime.go')
-rw-r--r-- | cmd/podman/libpodruntime/runtime.go | 16 |
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 |