Skip to content

Commit

Permalink
Add completion for kubectl set image
Browse files Browse the repository at this point in the history
  • Loading branch information
ah8ad3 committed May 7, 2024
1 parent 7b73ee0 commit ee58214
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/set/set_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/polymorphichelpers"
"k8s.io/kubectl/pkg/scheme"
"k8s.io/kubectl/pkg/util/completion"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
)
Expand Down Expand Up @@ -112,13 +113,15 @@ func NewImageOptions(streams genericiooptions.IOStreams) *SetImageOptions {
// NewCmdImage returns an initialized Command instance for the 'set image' sub command
func NewCmdImage(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
o := NewImageOptions(streams)
validArgs := []string{"daemonsets", "deployments", "pods", "cronjobs", "replicasets", "replicationcontrollers", "statefulsets"}

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

0 comments on commit ee58214

Please sign in to comment.