Skip to content

Commit

Permalink
Merge pull request containers#16722 from rhatdan/completions
Browse files Browse the repository at this point in the history
Add completion for --init-ctr
  • Loading branch information
openshift-merge-robot authored Dec 5, 2022
2 parents b26d4fc + 39b6ccb commit f223bba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 7 additions & 0 deletions cmd/podman/common/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions cmd/podman/containers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -86,8 +86,6 @@ func createFlags(cmd *cobra.Command) {

_ = flags.MarkHidden("pidfile")
}

_ = cmd.RegisterFlagCompletionFunc(initContainerFlagName, completion.AutocompleteDefault)
}

func init() {
Expand Down

0 comments on commit f223bba

Please sign in to comment.