From 96031aaca56bfb21952cb6c6957dde272a74e163 Mon Sep 17 00:00:00 2001 From: Janet Kuo Date: Wed, 2 Sep 2015 15:38:40 -0700 Subject: [PATCH] Get printer from factory instead of using NewHumanReadablePrinter to retrieve handled resources --- contrib/completions/bash/kubectl | 1 + pkg/kubectl/cmd/delete.go | 11 ++++++++--- pkg/kubectl/cmd/get.go | 10 ++++++++-- pkg/kubectl/cmd/label.go | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index b834a86522b..c096937e22c 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -845,6 +845,7 @@ _kubectl_label() must_have_one_flag=() must_have_one_noun=() must_have_one_noun+=("componentstatus") + must_have_one_noun+=("deployment") must_have_one_noun+=("endpoints") must_have_one_noun+=("event") must_have_one_noun+=("limitrange") diff --git a/pkg/kubectl/cmd/delete.go b/pkg/kubectl/cmd/delete.go index fd17b30ad57..7baaba3967f 100644 --- a/pkg/kubectl/cmd/delete.go +++ b/pkg/kubectl/cmd/delete.go @@ -67,11 +67,16 @@ $ kubectl delete pods --all` ) func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command { - p := kubectl.NewHumanReadablePrinter(false, false, false, false, []string{}) - validArgs := p.HandledResources() - options := &DeleteOptions{} + // retrieve a list of handled resources from printer as valid args + validArgs := []string{} + p, err := f.Printer(nil, false, false, false, false, []string{}) + cmdutil.CheckErr(err) + if p != nil { + validArgs = p.HandledResources() + } + cmd := &cobra.Command{ Use: "delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)])", Short: "Delete resources by filenames, stdin, resources and names, or by resources and label selector.", diff --git a/pkg/kubectl/cmd/get.go b/pkg/kubectl/cmd/get.go index 097183c02fb..ac8194a5f1d 100644 --- a/pkg/kubectl/cmd/get.go +++ b/pkg/kubectl/cmd/get.go @@ -74,10 +74,16 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7` // NewCmdGet creates a command object for the generic "get" action, which // retrieves one or more resources from a server. func NewCmdGet(f *cmdutil.Factory, out io.Writer) *cobra.Command { - p := kubectl.NewHumanReadablePrinter(false, false, false, false, []string{}) - validArgs := p.HandledResources() options := &GetOptions{} + // retrieve a list of handled resources from printer as valid args + validArgs := []string{} + p, err := f.Printer(nil, false, false, false, false, []string{}) + cmdutil.CheckErr(err) + if p != nil { + validArgs = p.HandledResources() + } + cmd := &cobra.Command{ Use: "get [(-o|--output=)json|yaml|template|templatefile|wide|jsonpath|...] (TYPE [NAME | -l label] | TYPE/NAME ...) [flags]", Short: "Display one or many resources", diff --git a/pkg/kubectl/cmd/label.go b/pkg/kubectl/cmd/label.go index 333416db8ca..cb2630b2310 100644 --- a/pkg/kubectl/cmd/label.go +++ b/pkg/kubectl/cmd/label.go @@ -65,6 +65,8 @@ $ kubectl label pods foo bar-` func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command { options := &LabelOptions{} + + // retrieve a list of handled resources from printer as valid args validArgs := []string{} p, err := f.Printer(nil, false, false, false, false, []string{}) cmdutil.CheckErr(err)