From 82a948c04ec068acb9f0d47dc0f9e3bd05b4c90c Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 20 Jun 2018 17:08:18 -0400 Subject: 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 Closes: #975 Approved by: mheon --- pkg/spec/createconfig.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'pkg/spec/createconfig.go') diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 36a6e83f2..205e08c57 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -413,6 +413,27 @@ func (c *CreateConfig) GetContainerCreateOptions() ([]libpod.CtrCreateOption, er } options = append(options, libpod.WithPrivileged(c.Privileged)) + + useImageVolumes := c.ImageVolumeType == "bind" + // Gather up the options for NewContainer which consist of With... funcs + options = append(options, libpod.WithRootFSFromImage(c.ImageID, c.Image, useImageVolumes)) + options = append(options, libpod.WithSELinuxLabels(c.ProcessLabel, c.MountLabel)) + options = append(options, libpod.WithConmonPidFile(c.ConmonPidFile)) + options = append(options, libpod.WithLabels(c.Labels)) + options = append(options, libpod.WithUser(c.User)) + options = append(options, libpod.WithShmDir(c.ShmDir)) + options = append(options, libpod.WithShmSize(c.Resources.ShmSize)) + options = append(options, libpod.WithGroups(c.GroupAdd)) + options = append(options, libpod.WithIDMappings(*c.IDMappings)) + if c.Rootfs != "" { + options = append(options, libpod.WithRootFS(c.Rootfs)) + } + // Default used if not overridden on command line + + if c.CgroupParent != "" { + options = append(options, libpod.WithCgroupParent(c.CgroupParent)) + } + return options, nil } -- cgit v1.2.3-54-g00ecf