Skip to content

Commit 0590bb1

Browse files
authored
Merge pull request kubernetes#124592 from ah8ad3/add-kubectl-set-completion
Add completion for kubectl set image
2 parents 1dc30bf + ee58214 commit 0590bb1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

staging/src/k8s.io/kubectl/pkg/cmd/set/set_image.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
cmdutil "k8s.io/kubectl/pkg/cmd/util"
3535
"k8s.io/kubectl/pkg/polymorphichelpers"
3636
"k8s.io/kubectl/pkg/scheme"
37+
"k8s.io/kubectl/pkg/util/completion"
3738
"k8s.io/kubectl/pkg/util/i18n"
3839
"k8s.io/kubectl/pkg/util/templates"
3940
)
@@ -112,13 +113,15 @@ func NewImageOptions(streams genericiooptions.IOStreams) *SetImageOptions {
112113
// NewCmdImage returns an initialized Command instance for the 'set image' sub command
113114
func NewCmdImage(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
114115
o := NewImageOptions(streams)
116+
validArgs := []string{"daemonsets", "deployments", "pods", "cronjobs", "replicasets", "replicationcontrollers", "statefulsets"}
115117

116118
cmd := &cobra.Command{
117119
Use: "image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N",
118120
DisableFlagsInUseLine: true,
119121
Short: i18n.T("Update the image of a pod template"),
120122
Long: imageLong,
121123
Example: imageExample,
124+
ValidArgsFunction: completion.SpecifiedResourceTypeAndNameNoRepeatCompletionFunc(f, validArgs),
122125
Run: func(cmd *cobra.Command, args []string) {
123126
cmdutil.CheckErr(o.Complete(f, cmd, args))
124127
cmdutil.CheckErr(o.Validate())

0 commit comments

Comments
 (0)