diff --git a/pkg/kubectl/cmd/get/get.go b/pkg/kubectl/cmd/get/get.go index 3ca8eb4a11dcd..d62605c81287a 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) }