Skip to content

Commit

Permalink
Merge pull request kubernetes#79968 from sukeesh/improveNoResource
Browse files Browse the repository at this point in the history
Flush out current namespace when resources are not found
  • Loading branch information
k8s-ci-robot authored Jul 11, 2019
2 parents a7c619a + b7d2478 commit 12c5e20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/kubectl/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubectl/cmd/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 12c5e20

Please sign in to comment.