From b7d2478ac9875f26250ea0803d92b58fe543e4a1 Mon Sep 17 00:00:00 2001 From: Sukeesh Date: Wed, 10 Jul 2019 16:12:48 +0900 Subject: [PATCH] flush current namespace when resources are not found --- pkg/kubectl/cmd/get/get.go | 3 ++- pkg/kubectl/cmd/get/get_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/get/get.go b/pkg/kubectl/cmd/get/get.go index 02b8d513d5a..352f63ae353 100644 --- a/pkg/kubectl/cmd/get/get.go +++ b/pkg/kubectl/cmd/get/get.go @@ -575,7 +575,8 @@ 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 - fmt.Fprintln(o.ErrOut, "No resources found.") + noResourcesFoundFormat := fmt.Sprintf("No resources found in %s namespace.", o.Namespace) + fmt.Fprintln(o.ErrOut, noResourcesFoundFormat) } return utilerrors.NewAggregate(allErrs) } diff --git a/pkg/kubectl/cmd/get/get_test.go b/pkg/kubectl/cmd/get/get_test.go index 5de94dd8b75..f906bbb458c 100644 --- a/pkg/kubectl/cmd/get/get_test.go +++ b/pkg/kubectl/cmd/get/get_test.go @@ -513,7 +513,7 @@ func TestGetEmptyTable(t *testing.T) { if e, a := expected, buf.String(); e != a { t.Errorf("expected\n%v\ngot\n%v", e, a) } - expectedErr := `No resources found. + expectedErr := `No resources found in test namespace. ` if e, a := expectedErr, errbuf.String(); e != a { t.Errorf("expectedErr\n%v\ngot\n%v", e, a)