diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go index 7595205bb8..6c74002281 100644 --- a/cmd/podman/common/completion.go +++ b/cmd/podman/common/completion.go @@ -906,6 +906,13 @@ func AutocompleteImageFormat(cmd *cobra.Command, args []string, toComplete strin return ImageFormat, cobra.ShellCompDirectiveNoFileComp } +// AutocompleteInitCtr - Autocomplete init container type +// -> "once", "always" +func AutocompleteInitCtr(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + InitCtrType := []string{define.AlwaysInitContainer, define.OneShotInitContainer} + return InitCtrType, cobra.ShellCompDirectiveNoFileComp +} + // AutocompleteCreateAttach - Autocomplete create --attach options. // -> "stdin", "stdout", "stderr" func AutocompleteCreateAttach(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index a73b3975be..e15877023f 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -8,7 +8,6 @@ import ( "strconv" "strings" - "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/config" cutil "github.com/containers/common/pkg/util" "github.com/containers/image/v5/transports/alltransports" @@ -69,6 +68,7 @@ func createFlags(cmd *cobra.Command) { initContainerFlagName, "", "Make this a pod init container.", ) + _ = cmd.RegisterFlagCompletionFunc(initContainerFlagName, common.AutocompleteInitCtr) flags.SetInterspersed(false) common.DefineCreateDefaults(&cliVals) @@ -86,8 +86,6 @@ func createFlags(cmd *cobra.Command) { _ = flags.MarkHidden("pidfile") } - - _ = cmd.RegisterFlagCompletionFunc(initContainerFlagName, completion.AutocompleteDefault) } func init() {