diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/common/create.go | 8 | ||||
-rw-r--r-- | cmd/podman/common/create_opts.go | 2 | ||||
-rw-r--r-- | cmd/podman/common/specgen.go | 8 | ||||
-rw-r--r-- | cmd/podman/containers/create.go | 24 |
4 files changed, 41 insertions, 1 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 96414add4..602ad5d94 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -498,6 +498,14 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) { ) _ = cmd.RegisterFlagCompletionFunc(variantFlagName, completion.AutocompleteNone) + personalityFlagName := "personality" + createFlags.StringVar( + &cf.Personality, + personalityFlagName, "", + "Configure execution domain using personality (e.g., LINUX/LINUX32)", + ) + _ = cmd.RegisterFlagCompletionFunc(personalityFlagName, AutocompleteNamespace) + pidFlagName := "pid" createFlags.String( pidFlagName, "", diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 42e0efe5d..0a969bfd2 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -61,6 +61,7 @@ type ContainerCLIOpts struct { HTTPProxy bool ImageVolume string Init bool + InitContainerType string InitPath string Interactive bool IPC string @@ -80,6 +81,7 @@ type ContainerCLIOpts struct { Arch string OS string Variant string + Personality string PID string PIDsLimit *int64 Platform string diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 42f515ace..8d6a21cb7 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -651,6 +651,12 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string if err != nil { return err } + + if c.Personality != "" { + s.Personality = &specs.LinuxPersonality{} + s.Personality.Domain = specs.LinuxPersonalityDomain(c.Personality) + } + s.Remove = c.Rm s.StopTimeout = &c.StopTimeout s.Timeout = c.Timeout @@ -659,6 +665,8 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string s.PidFile = c.PidFile s.Volatile = c.Rm + // Initcontainers + s.InitContainerType = c.InitContainerType return nil } diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index c63c074f7..895736144 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" + "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/config" "github.com/containers/image/v5/transports/alltransports" "github.com/containers/podman/v3/cmd/podman/common" @@ -49,12 +50,20 @@ var ( ) var ( - cliVals common.ContainerCLIOpts + cliVals common.ContainerCLIOpts + InitContainerType string ) func createFlags(cmd *cobra.Command) { flags := cmd.Flags() + initContainerFlagName := "init-ctr" + flags.StringVar( + &InitContainerType, + initContainerFlagName, "", + "Make this a pod init container.", + ) + flags.SetInterspersed(false) common.DefineCreateFlags(cmd, &cliVals) common.DefineNetFlags(cmd) @@ -65,6 +74,8 @@ func createFlags(cmd *cobra.Command) { _ = flags.MarkHidden("conmon-pidfile") _ = flags.MarkHidden("pidfile") } + + _ = cmd.RegisterFlagCompletionFunc(initContainerFlagName, completion.AutocompleteDefault) } func init() { @@ -89,6 +100,17 @@ func create(cmd *cobra.Command, args []string) error { return err } + // Check if initctr is used with --pod and the value is correct + if initctr := InitContainerType; cmd.Flags().Changed("init-ctr") { + if !cmd.Flags().Changed("pod") { + return errors.New("must specify pod value with init-ctr") + } + if !util.StringInSlice(initctr, []string{"always", "oneshot"}) { + return errors.New("init-ctr value must be 'always' or 'oneshot'") + } + cliVals.InitContainerType = initctr + } + if err := createInit(cmd); err != nil { return err } |