diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index 8e1a9ccc0cb..afa2f4e7116 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -833,6 +833,21 @@ _kubectl_label() must_have_one_flag=() must_have_one_noun=() + must_have_one_noun+=("componentstatus") + must_have_one_noun+=("endpoints") + must_have_one_noun+=("event") + must_have_one_noun+=("limitrange") + must_have_one_noun+=("namespace") + must_have_one_noun+=("node") + must_have_one_noun+=("persistentvolume") + must_have_one_noun+=("persistentvolumeclaim") + must_have_one_noun+=("pod") + must_have_one_noun+=("podtemplate") + must_have_one_noun+=("replicationcontroller") + must_have_one_noun+=("resourcequota") + must_have_one_noun+=("secret") + must_have_one_noun+=("service") + must_have_one_noun+=("serviceaccount") } _kubectl_annotate() diff --git a/pkg/kubectl/cmd/label.go b/pkg/kubectl/cmd/label.go index 42aba6ac6b1..d0f408e9122 100644 --- a/pkg/kubectl/cmd/label.go +++ b/pkg/kubectl/cmd/label.go @@ -64,6 +64,8 @@ $ kubectl label pods foo bar-` func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command { options := &LabelOptions{} + p := kubectl.NewHumanReadablePrinter(false, false, false, false, []string{}) + validArgs := p.HandledResources() cmd := &cobra.Command{ Use: "label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]", @@ -74,6 +76,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command { err := RunLabel(f, out, cmd, args, options) cmdutil.CheckErr(err) }, + ValidArgs: validArgs, } cmdutil.AddPrinterFlags(cmd) cmd.Flags().Bool("overwrite", false, "If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.")