summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-06-20 17:08:18 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-22 14:30:18 +0000
commit82a948c04ec068acb9f0d47dc0f9e3bd05b4c90c (patch)
treef28917f2e37ea0cc2b4523cc9c6f1d4c4c4049cd /cmd/podman
parentbb4db6d54873c05d0654ab848c09c24a76c95a73 (diff)
downloadpodman-82a948c04ec068acb9f0d47dc0f9e3bd05b4c90c.tar.gz
podman-82a948c04ec068acb9f0d47dc0f9e3bd05b4c90c.tar.bz2
podman-82a948c04ec068acb9f0d47dc0f9e3bd05b4c90c.zip
Option handling has become large and should be a shared function
Everytime we add a new option for create, we end up having to also add it to run, this makes it error prone. Moving these to the same function makes it easier to develop and prevents user mistakes. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #975 Approved by: mheon
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/create.go18
-rw-r--r--cmd/podman/run.go23
2 files changed, 4 insertions, 37 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 52d6e32f6..440406903 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -110,29 +110,17 @@ func createCmd(c *cli.Context) error {
if err != nil {
return err
}
- useImageVolumes := createConfig.ImageVolumeType == "bind"
runtimeSpec, err := cc.CreateConfigToOCISpec(createConfig)
if err != nil {
return err
}
+
options, err := createConfig.GetContainerCreateOptions()
if err != nil {
- return errors.Wrapf(err, "unable to parse new container options")
- }
- // Gather up the options for NewContainer which consist of With... funcs
- options = append(options, libpod.WithRootFSFromImage(createConfig.ImageID, createConfig.Image, useImageVolumes))
- options = append(options, libpod.WithSELinuxLabels(createConfig.ProcessLabel, createConfig.MountLabel))
- options = append(options, libpod.WithConmonPidFile(createConfig.ConmonPidFile))
- options = append(options, libpod.WithLabels(createConfig.Labels))
- options = append(options, libpod.WithUser(createConfig.User))
- options = append(options, libpod.WithShmDir(createConfig.ShmDir))
- options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize))
- options = append(options, libpod.WithGroups(createConfig.GroupAdd))
- options = append(options, libpod.WithIDMappings(*createConfig.IDMappings))
- if createConfig.Rootfs != "" {
- options = append(options, libpod.WithRootFS(createConfig.Rootfs))
+ return err
}
+
ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)
if err != nil {
return err
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index b7516a233..421b868ad 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -104,7 +104,6 @@ func runCmd(c *cli.Context) error {
if err != nil {
return err
}
- useImageVolumes := createConfig.ImageVolumeType == "bind"
runtimeSpec, err := cc.CreateConfigToOCISpec(createConfig)
if err != nil {
@@ -113,27 +112,7 @@ func runCmd(c *cli.Context) error {
options, err := createConfig.GetContainerCreateOptions()
if err != nil {
- return errors.Wrapf(err, "unable to parse new container options")
- }
-
- // Gather up the options for NewContainer which consist of With... funcs
- options = append(options, libpod.WithRootFSFromImage(createConfig.ImageID, createConfig.Image, useImageVolumes))
- options = append(options, libpod.WithSELinuxLabels(createConfig.ProcessLabel, createConfig.MountLabel))
- options = append(options, libpod.WithConmonPidFile(createConfig.ConmonPidFile))
- options = append(options, libpod.WithLabels(createConfig.Labels))
- options = append(options, libpod.WithUser(createConfig.User))
- options = append(options, libpod.WithShmDir(createConfig.ShmDir))
- options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize))
- options = append(options, libpod.WithGroups(createConfig.GroupAdd))
- options = append(options, libpod.WithIDMappings(*createConfig.IDMappings))
- if createConfig.Rootfs != "" {
- options = append(options, libpod.WithRootFS(createConfig.Rootfs))
- }
-
- // Default used if not overridden on command line
-
- if createConfig.CgroupParent != "" {
- options = append(options, libpod.WithCgroupParent(createConfig.CgroupParent))
+ return err
}
ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)