mirror of https://github.com/knative/client.git
Fix resource listing with -oname flag (#799)
* Fix resource listing with -oname flag * add e2e tests
This commit is contained in:
parent
88109bd439
commit
2225b4c8dd
|
|
@ -103,12 +103,7 @@ func NewRevisionListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
sortRevisions(revisionList)
|
sortRevisions(revisionList)
|
||||||
|
|
||||||
// Print out infos via printer framework
|
// Print out infos via printer framework
|
||||||
printer, err := revisionListFlags.ToPrinter()
|
return revisionListFlags.Print(revisionList, cmd.OutOrStdout())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return printer.PrintObj(revisionList, cmd.OutOrStdout())
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
commands.AddNamespaceFlags(revisionListCommand.Flags(), true)
|
commands.AddNamespaceFlags(revisionListCommand.Flags(), true)
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,7 @@ func NewRouteListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "No routes found.\n")
|
fmt.Fprintf(cmd.OutOrStdout(), "No routes found.\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
printer, err := routeListFlags.ToPrinter()
|
err = routeListFlags.Print(routeList, cmd.OutOrStdout())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = printer.PrintObj(routeList, cmd.OutOrStdout())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,7 @@ func NewAPIServerListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
listFlags.EnsureWithNamespace()
|
listFlags.EnsureWithNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
printer, err := listFlags.ToPrinter()
|
err = listFlags.Print(sourceList, cmd.OutOrStdout())
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err = printer.PrintObj(sourceList, cmd.OutOrStdout())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,12 +58,7 @@ func NewBindingListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
listFlags.EnsureWithNamespace()
|
listFlags.EnsureWithNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
printer, err := listFlags.ToPrinter()
|
err = listFlags.Print(sourceList, cmd.OutOrStdout())
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err = printer.PrintObj(sourceList, cmd.OutOrStdout())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,7 @@ func NewPingListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
listFlags.EnsureWithNamespace()
|
listFlags.EnsureWithNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
printer, err := listFlags.ToPrinter()
|
err = listFlags.Print(sourceList, cmd.OutOrStdout())
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
err = printer.PrintObj(sourceList, cmd.OutOrStdout())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,7 @@ func NewTriggerListCommand(p *commands.KnParams) *cobra.Command {
|
||||||
triggerListFlags.EnsureWithNamespace()
|
triggerListFlags.EnsureWithNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
printer, err := triggerListFlags.ToPrinter()
|
err = triggerListFlags.Print(triggerList, cmd.OutOrStdout())
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = printer.PrintObj(triggerList, cmd.OutOrStdout())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ func TestSourcePing(t *testing.T) {
|
||||||
t.Log("create Ping sources with a sink to a service")
|
t.Log("create Ping sources with a sink to a service")
|
||||||
|
|
||||||
pingSourceCreate(r, "testpingsource0", "* * * * */1", "ping", "svc:testsvc0")
|
pingSourceCreate(r, "testpingsource0", "* * * * */1", "ping", "svc:testsvc0")
|
||||||
|
pingSourceListOutputName(r, "testpingsource0")
|
||||||
|
|
||||||
t.Log("delete Ping sources")
|
t.Log("delete Ping sources")
|
||||||
pingSourceDelete(r, "testpingsource0")
|
pingSourceDelete(r, "testpingsource0")
|
||||||
|
|
@ -76,7 +77,12 @@ func pingSourceDelete(r *test.KnRunResultCollector, sourceName string) {
|
||||||
out := r.KnTest().Kn().Run("source", "ping", "delete", sourceName)
|
out := r.KnTest().Kn().Run("source", "ping", "delete", sourceName)
|
||||||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "ping", "source", sourceName, "deleted", "namespace", r.KnTest().Kn().Namespace()))
|
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "ping", "source", sourceName, "deleted", "namespace", r.KnTest().Kn().Namespace()))
|
||||||
r.AssertNoError(out)
|
r.AssertNoError(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func pingSourceListOutputName(r *test.KnRunResultCollector, pingSource string) {
|
||||||
|
out := r.KnTest().Kn().Run("source", "ping", "list", "--output", "name")
|
||||||
|
r.AssertNoError(out)
|
||||||
|
assert.Check(r.T(), util.ContainsAll(out.Stdout, pingSource))
|
||||||
}
|
}
|
||||||
|
|
||||||
func pingSourceCreateMissingSink(r *test.KnRunResultCollector, sourceName string, schedule string, data string, sink string) {
|
func pingSourceCreateMissingSink(r *test.KnRunResultCollector, sourceName string, schedule string, data string, sink string) {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ func TestRevision(t *testing.T) {
|
||||||
|
|
||||||
t.Log("describe revision from hello service with print flags")
|
t.Log("describe revision from hello service with print flags")
|
||||||
revName := findRevision(r, "hello")
|
revName := findRevision(r, "hello")
|
||||||
|
revisionListOutputName(r, revName)
|
||||||
revisionDescribeWithPrintFlags(r, revName)
|
revisionDescribeWithPrintFlags(r, revName)
|
||||||
|
|
||||||
t.Log("update hello service and increase revision count to 2")
|
t.Log("update hello service and increase revision count to 2")
|
||||||
|
|
@ -70,6 +71,12 @@ func TestRevision(t *testing.T) {
|
||||||
serviceDelete(r, "hello")
|
serviceDelete(r, "hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func revisionListOutputName(r *test.KnRunResultCollector, revisionName string) {
|
||||||
|
out := r.KnTest().Kn().Run("revision", "list", "--output", "name")
|
||||||
|
r.AssertNoError(out)
|
||||||
|
assert.Check(r.T(), util.ContainsAll(out.Stdout, revisionName, "revision.serving.knative.dev"))
|
||||||
|
}
|
||||||
|
|
||||||
func revisionListWithService(r *test.KnRunResultCollector, serviceNames ...string) {
|
func revisionListWithService(r *test.KnRunResultCollector, serviceNames ...string) {
|
||||||
for _, svcName := range serviceNames {
|
for _, svcName := range serviceNames {
|
||||||
confGen := findConfigurationGeneration(r, svcName)
|
confGen := findConfigurationGeneration(r, svcName)
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ func TestRoute(t *testing.T) {
|
||||||
t.Log("return a list of routes associated with hello service")
|
t.Log("return a list of routes associated with hello service")
|
||||||
routeListWithArgument(r, "hello")
|
routeListWithArgument(r, "hello")
|
||||||
|
|
||||||
|
t.Log("return a list of routes associated with hello service with -oname flag")
|
||||||
|
routeListOutputName(r, "hello")
|
||||||
|
|
||||||
t.Log("return a list of routes associated with hello service with print flags")
|
t.Log("return a list of routes associated with hello service with print flags")
|
||||||
routeListWithPrintFlags(r, "hello")
|
routeListWithPrintFlags(r, "hello")
|
||||||
|
|
||||||
|
|
@ -69,6 +72,12 @@ func routeList(r *test.KnRunResultCollector) {
|
||||||
r.AssertNoError(out)
|
r.AssertNoError(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func routeListOutputName(r *test.KnRunResultCollector, routeName string) {
|
||||||
|
out := r.KnTest().Kn().Run("route", "list", "--output", "name")
|
||||||
|
r.AssertNoError(out)
|
||||||
|
assert.Check(r.T(), util.ContainsAll(out.Stdout, routeName, "route.serving.knative.dev"))
|
||||||
|
}
|
||||||
|
|
||||||
func routeListWithArgument(r *test.KnRunResultCollector, routeName string) {
|
func routeListWithArgument(r *test.KnRunResultCollector, routeName string) {
|
||||||
out := r.KnTest().Kn().Run("route", "list", routeName)
|
out := r.KnTest().Kn().Run("route", "list", routeName)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ func TestSourceApiServer(t *testing.T) {
|
||||||
t.Log("create apiserver sources with a sink to a service")
|
t.Log("create apiserver sources with a sink to a service")
|
||||||
apiServerSourceCreate(r, "testapisource0", "Event:v1:true", "testsa", "svc:testsvc0")
|
apiServerSourceCreate(r, "testapisource0", "Event:v1:true", "testsa", "svc:testsvc0")
|
||||||
apiServerSourceCreate(r, "testapisource1", "Event:v1", "testsa", "svc:testsvc0")
|
apiServerSourceCreate(r, "testapisource1", "Event:v1", "testsa", "svc:testsvc0")
|
||||||
|
apiServerSourceListOutputName(r, "testapisource0", "testapisource1")
|
||||||
|
|
||||||
t.Log("list sources")
|
t.Log("list sources")
|
||||||
output := sourceList(r)
|
output := sourceList(r)
|
||||||
|
|
@ -91,6 +92,12 @@ func apiServerSourceCreate(r *test.KnRunResultCollector, sourceName string, reso
|
||||||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "apiserver", "source", sourceName, "created", "namespace", r.KnTest().Kn().Namespace()))
|
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "apiserver", "source", sourceName, "created", "namespace", r.KnTest().Kn().Namespace()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func apiServerSourceListOutputName(r *test.KnRunResultCollector, apiserverSources ...string) {
|
||||||
|
out := r.KnTest().Kn().Run("source", "apiserver", "list", "--output", "name")
|
||||||
|
r.AssertNoError(out)
|
||||||
|
assert.Check(r.T(), util.ContainsAll(out.Stdout, apiserverSources...))
|
||||||
|
}
|
||||||
|
|
||||||
func apiServerSourceCreateMissingSink(r *test.KnRunResultCollector, sourceName string, resources string, sa string, sink string) {
|
func apiServerSourceCreateMissingSink(r *test.KnRunResultCollector, sourceName string, resources string, sa string, sink string) {
|
||||||
out := r.KnTest().Kn().Run("source", "apiserver", "create", sourceName, "--resource", resources, "--service-account", sa, "--sink", sink)
|
out := r.KnTest().Kn().Run("source", "apiserver", "create", sourceName, "--resource", resources, "--service-account", sa, "--sink", sink)
|
||||||
r.AssertError(out)
|
r.AssertError(out)
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ func TestSourceBinding(t *testing.T) {
|
||||||
|
|
||||||
t.Log("create source binding")
|
t.Log("create source binding")
|
||||||
sourceBindingCreate(r, "my-binding0", "Deployment:apps/v1:myapp", "svc:testsvc0")
|
sourceBindingCreate(r, "my-binding0", "Deployment:apps/v1:myapp", "svc:testsvc0")
|
||||||
|
sourceBindingListOutputName(r, "my-binding0")
|
||||||
|
|
||||||
t.Log("delete source binding")
|
t.Log("delete source binding")
|
||||||
sourceBindingDelete(r, "my-binding0")
|
sourceBindingDelete(r, "my-binding0")
|
||||||
|
|
@ -72,3 +73,9 @@ func sourceBindingUpdate(r *test.KnRunResultCollector, bindingName string, subje
|
||||||
r.AssertNoError(out)
|
r.AssertNoError(out)
|
||||||
assert.Check(r.T(), util.ContainsAll(out.Stdout, bindingName, "updated", "namespace", r.KnTest().Kn().Namespace()))
|
assert.Check(r.T(), util.ContainsAll(out.Stdout, bindingName, "updated", "namespace", r.KnTest().Kn().Namespace()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sourceBindingListOutputName(r *test.KnRunResultCollector, bindingName string) {
|
||||||
|
out := r.KnTest().Kn().Run("source", "binding", "list", "--output", "name")
|
||||||
|
r.AssertNoError(out)
|
||||||
|
assert.Check(r.T(), util.ContainsAll(out.Stdout, bindingName))
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ func TestBrokerTrigger(t *testing.T) {
|
||||||
triggerCreate(r, "trigger1", "sinksvc0", []string{"a=b"})
|
triggerCreate(r, "trigger1", "sinksvc0", []string{"a=b"})
|
||||||
triggerCreate(r, "trigger2", "sinksvc1", []string{"type=knative.dev.bar", "source=ping"})
|
triggerCreate(r, "trigger2", "sinksvc1", []string{"type=knative.dev.bar", "source=ping"})
|
||||||
verifyTriggerList(r, "trigger1", "trigger2")
|
verifyTriggerList(r, "trigger1", "trigger2")
|
||||||
|
verifyTriggerListOutputName(r, "trigger1", "trigger2")
|
||||||
triggerDelete(r, "trigger1")
|
triggerDelete(r, "trigger1")
|
||||||
triggerDelete(r, "trigger2")
|
triggerDelete(r, "trigger2")
|
||||||
|
|
||||||
|
|
@ -141,6 +142,12 @@ func verifyTriggerList(r *test.KnRunResultCollector, triggers ...string) {
|
||||||
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, triggers...))
|
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, triggers...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func verifyTriggerListOutputName(r *test.KnRunResultCollector, triggers ...string) {
|
||||||
|
out := r.KnTest().Kn().Run("trigger", "list", "--output", "name")
|
||||||
|
r.AssertNoError(out)
|
||||||
|
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, triggers...))
|
||||||
|
}
|
||||||
|
|
||||||
func verifyTriggerDescribe(r *test.KnRunResultCollector, name string, broker string, sink string, filters []string) {
|
func verifyTriggerDescribe(r *test.KnRunResultCollector, name string, broker string, sink string, filters []string) {
|
||||||
out := r.KnTest().Kn().Run("trigger", "describe", name)
|
out := r.KnTest().Kn().Run("trigger", "describe", name)
|
||||||
r.AssertNoError(out)
|
r.AssertNoError(out)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue