From e1ee01af48eadd89ff08a8364e84c1ea65252f00 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Fri, 2 Aug 2019 14:13:48 -0700 Subject: [PATCH] Omit namespace when kubectl get is for the cluster --- pkg/kubectl/cmd/get/get.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/get/get.go b/pkg/kubectl/cmd/get/get.go index 3ca8eb4a11d..d62605c8128 100644 --- a/pkg/kubectl/cmd/get/get.go +++ b/pkg/kubectl/cmd/get/get.go @@ -581,8 +581,11 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e w.Flush() if trackingWriter.Written == 0 && !o.IgnoreNotFound && len(allErrs) == 0 { // if we wrote no output, and had no errors, and are not ignoring NotFound, be sure we output something - noResourcesFoundFormat := fmt.Sprintf("No resources found in %s namespace.", o.Namespace) - fmt.Fprintln(o.ErrOut, noResourcesFoundFormat) + if !o.AllNamespaces { + fmt.Fprintln(o.ErrOut, fmt.Sprintf("No resources found in %s namespace.", o.Namespace)) + } else { + fmt.Fprintln(o.ErrOut, fmt.Sprintf("No resources found")) + } } return utilerrors.NewAggregate(allErrs) }