mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
Merge pull request #124592 from ah8ad3/add-kubectl-set-completion
Add completion for kubectl set image
This commit is contained in:
commit
0590bb1ac4
@ -34,6 +34,7 @@ import (
|
|||||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||||
"k8s.io/kubectl/pkg/polymorphichelpers"
|
"k8s.io/kubectl/pkg/polymorphichelpers"
|
||||||
"k8s.io/kubectl/pkg/scheme"
|
"k8s.io/kubectl/pkg/scheme"
|
||||||
|
"k8s.io/kubectl/pkg/util/completion"
|
||||||
"k8s.io/kubectl/pkg/util/i18n"
|
"k8s.io/kubectl/pkg/util/i18n"
|
||||||
"k8s.io/kubectl/pkg/util/templates"
|
"k8s.io/kubectl/pkg/util/templates"
|
||||||
)
|
)
|
||||||
@ -112,6 +113,7 @@ func NewImageOptions(streams genericiooptions.IOStreams) *SetImageOptions {
|
|||||||
// NewCmdImage returns an initialized Command instance for the 'set image' sub command
|
// NewCmdImage returns an initialized Command instance for the 'set image' sub command
|
||||||
func NewCmdImage(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
|
func NewCmdImage(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
|
||||||
o := NewImageOptions(streams)
|
o := NewImageOptions(streams)
|
||||||
|
validArgs := []string{"daemonsets", "deployments", "pods", "cronjobs", "replicasets", "replicationcontrollers", "statefulsets"}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N",
|
Use: "image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N",
|
||||||
@ -119,6 +121,7 @@ func NewCmdImage(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.C
|
|||||||
Short: i18n.T("Update the image of a pod template"),
|
Short: i18n.T("Update the image of a pod template"),
|
||||||
Long: imageLong,
|
Long: imageLong,
|
||||||
Example: imageExample,
|
Example: imageExample,
|
||||||
|
ValidArgsFunction: completion.SpecifiedResourceTypeAndNameNoRepeatCompletionFunc(f, validArgs),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
cmdutil.CheckErr(o.Complete(f, cmd, args))
|
||||||
cmdutil.CheckErr(o.Validate())
|
cmdutil.CheckErr(o.Validate())
|
||||||
|
Loading…
Reference in New Issue
Block a user