chore(plugins, services, routes): Aligned "Not found" messages (#359)

For the sake of consistency with out own service commands and for kubectl,

`kn plugin list` should print:

```
No plugins found.
```

`kn service list` should print:

```
No services found.
```

and not `No resources found.` like it does now.

Same for `kn routes list`.
This commit is contained in:
Roland Huß 2019-08-22 09:23:32 +02:00 committed by Knative Prow Robot
parent d0dc3b75f3
commit 9625b5f4c5
7 changed files with 12 additions and 9 deletions

View File

@ -80,7 +80,9 @@ func listPlugins(cmd *cobra.Command, flags pluginListFlags) error {
if len(pluginsFound) == 0 { if len(pluginsFound) == 0 {
if flags.verbose { if flags.verbose {
fmt.Fprintf(out, "No plugins found in path %s\n", pluginPath) fmt.Fprintf(out, "No plugins found in path %s.\n", pluginPath)
} else {
fmt.Fprintln(out, "No plugins found.")
} }
return nil return nil
} }

View File

@ -124,7 +124,7 @@ func TestPluginList(t *testing.T) {
defer ctx.cleanup() defer ctx.cleanup()
err := ctx.execute("plugin", "list", "--lookup-plugins-in-path=true") err := ctx.execute("plugin", "list", "--lookup-plugins-in-path=true")
assert.NilError(t, err) assert.NilError(t, err)
assert.Equal(t, ctx.output(), "") assert.Equal(t, ctx.output(), "No plugins found.\n")
}) })
}) })
@ -224,7 +224,7 @@ func TestPluginList(t *testing.T) {
err := ctx.execute("plugin", "list") err := ctx.execute("plugin", "list")
assert.NilError(t, err) assert.NilError(t, err)
assert.Equal(t, ctx.output(), "") assert.Equal(t, ctx.output(), "No plugins found.\n")
}) })
}) })
} }

View File

@ -15,6 +15,7 @@
package route package route
import ( import (
"errors"
"fmt" "fmt"
"knative.dev/client/pkg/kn/commands" "knative.dev/client/pkg/kn/commands"
@ -57,13 +58,13 @@ func NewRouteListCommand(p *commands.KnParams) *cobra.Command {
case 1: case 1:
routeList, err = client.ListRoutes(v1alpha12.WithName(args[0])) routeList, err = client.ListRoutes(v1alpha12.WithName(args[0]))
default: default:
return fmt.Errorf("'kn route list' accepts maximum 1 argument.") return errors.New("'kn route list' accepts only one additional argument")
} }
if err != nil { if err != nil {
return err return err
} }
if len(routeList.Items) == 0 { if len(routeList.Items) == 0 {
fmt.Fprintf(cmd.OutOrStdout(), "No resources found.\n") fmt.Fprintf(cmd.OutOrStdout(), "No routes found.\n")
return nil return nil
} }
printer, err := routeListFlags.ToPrinter() printer, err := routeListFlags.ToPrinter()

View File

@ -54,7 +54,7 @@ func TestListEmpty(t *testing.T) {
t.Errorf("No action") t.Errorf("No action")
} else if !action.Matches("list", "routes") { } else if !action.Matches("list", "routes") {
t.Errorf("Bad action %v", action) t.Errorf("Bad action %v", action)
} else if output[0] != "No resources found." { } else if output[0] != "No routes found." {
t.Errorf("Bad output %s", output[0]) t.Errorf("Bad output %s", output[0])
} }
} }

View File

@ -54,7 +54,7 @@ func NewServiceListCommand(p *commands.KnParams) *cobra.Command {
return err return err
} }
if len(serviceList.Items) == 0 { if len(serviceList.Items) == 0 {
fmt.Fprintf(cmd.OutOrStdout(), "No resources found.\n") fmt.Fprintf(cmd.OutOrStdout(), "No services found.\n")
return nil return nil
} }

View File

@ -57,7 +57,7 @@ func TestListEmpty(t *testing.T) {
t.Errorf("No action") t.Errorf("No action")
} else if !action.Matches("list", "services") { } else if !action.Matches("list", "services") {
t.Errorf("Bad action %v", action) t.Errorf("Bad action %v", action)
} else if output[0] != "No resources found." { } else if output[0] != "No services found." {
t.Errorf("Bad output %s", output[0]) t.Errorf("Bad output %s", output[0])
} }
} }

View File

@ -75,7 +75,7 @@ func (test *e2eTest) serviceListEmpty(t *testing.T) {
out, err := test.kn.RunWithOpts([]string{"service", "list"}, runOpts{NoNamespace: false}) out, err := test.kn.RunWithOpts([]string{"service", "list"}, runOpts{NoNamespace: false})
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, util.ContainsAll(out, "No resources found.")) assert.Check(t, util.ContainsAll(out, "No services found."))
} }
func (test *e2eTest) serviceCreate(t *testing.T, serviceName string) { func (test *e2eTest) serviceCreate(t *testing.T, serviceName string) {