Skip to content

Commit

Permalink
Dont print separate section for owner references
Browse files Browse the repository at this point in the history
  • Loading branch information
navidshaikh committed Feb 10, 2020
1 parent ec9fa12 commit 3bf2396
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/cmd/kn_revision.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ kn revision [flags]

* [kn](kn.md) - Knative client
* [kn revision delete](kn_revision_delete.md) - Delete a revision.
* [kn revision describe](kn_revision_describe.md) - Show details of a given Revision
* [kn revision describe](kn_revision_describe.md) - Show details of a revision
* [kn revision list](kn_revision_list.md) - List available revisions.

4 changes: 2 additions & 2 deletions docs/cmd/kn_revision_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn revision describe

Show details of a given Revision
Show details of a revision

### Synopsis

Show details of a given Revision
Show details of a revision

```
kn revision describe NAME [flags]
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_route.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ kn route [flags]
### SEE ALSO

* [kn](kn.md) - Knative client
* [kn route describe](kn_route_describe.md) - Show details of a given Route
* [kn route describe](kn_route_describe.md) - Show details of a route
* [kn route list](kn_route_list.md) - List available routes.

4 changes: 2 additions & 2 deletions docs/cmd/kn_route_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn route describe

Show details of a given Route
Show details of a route

### Synopsis

Show details of a given Route
Show details of a route

```
kn route describe NAME [flags]
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kn service [flags]
* [kn](kn.md) - Knative client
* [kn service create](kn_service_create.md) - Create a service.
* [kn service delete](kn_service_delete.md) - Delete a service.
* [kn service describe](kn_service_describe.md) - Show details for a given service
* [kn service describe](kn_service_describe.md) - Show details of a service
* [kn service list](kn_service_list.md) - List available services.
* [kn service update](kn_service_update.md) - Update a service.

4 changes: 2 additions & 2 deletions docs/cmd/kn_service_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn service describe

Show details for a given service
Show details of a service

### Synopsis

Show details for a given service
Show details of a service

```
kn service describe NAME [flags]
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_source_binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ kn source binding [flags]
* [kn source](kn_source.md) - Event source command group
* [kn source binding create](kn_source_binding_create.md) - Create a sink binding.
* [kn source binding delete](kn_source_binding_delete.md) - Delete a sink binding.
* [kn source binding describe](kn_source_binding_describe.md) - Describe a sink binding.
* [kn source binding describe](kn_source_binding_describe.md) - Show details of a sink binding
* [kn source binding list](kn_source_binding_list.md) - List sink bindings.
* [kn source binding update](kn_source_binding_update.md) - Update a sink binding.

4 changes: 2 additions & 2 deletions docs/cmd/kn_source_binding_describe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn source binding describe

Describe a sink binding.
Show details of a sink binding

### Synopsis

Describe a sink binding.
Show details of a sink binding

```
kn source binding describe NAME [flags]
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/revision/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewRevisionDescribeCommand(p *commands.KnParams) *cobra.Command {

command := &cobra.Command{
Use: "describe NAME",
Short: "Show details of a given Revision",
Short: "Show details of a revision",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("'kn revision describe' requires name of the revision as single argument")
Expand Down
20 changes: 8 additions & 12 deletions pkg/kn/commands/route/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewRouteDescribeCommand(p *commands.KnParams) *cobra.Command {
machineReadablePrintFlags := genericclioptions.NewPrintFlags("")
command := &cobra.Command{
Use: "describe NAME",
Short: "Show details of a given Route",
Short: "Show details of a route",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("'kn route describe' requires name of the route as single argument")
Expand Down Expand Up @@ -64,7 +64,6 @@ func NewRouteDescribeCommand(p *commands.KnParams) *cobra.Command {
if err != nil {
return err
}

return describe(cmd.OutOrStdout(), route, printDetails)
},
}
Expand All @@ -79,31 +78,28 @@ func describe(w io.Writer, route *servingv1.Route, printDetails bool) error {
dw := printers.NewPrefixWriter(w)
commands.WriteMetadata(dw, &route.ObjectMeta, printDetails)
dw.WriteAttribute("URL", route.Status.URL.String())
dw.WriteLine()
writeOwnerReferences(dw, route, printDetails)
writeService(dw, route, printDetails)
dw.WriteLine()
writeTraffic(dw, route)

dw.WriteLine()
commands.WriteConditions(dw, route.Status.Conditions, printDetails)
if err := dw.Flush(); err != nil {
return err
}

return nil
}

func writeOwnerReferences(dw printers.PrefixWriter, route *servingv1.Route, printDetails bool) {
ownerSection := dw.WriteAttribute("Owner References", "")
dw.Flush()
func writeService(dw printers.PrefixWriter, route *servingv1.Route, printDetails bool) {
for _, owner := range route.ObjectMeta.OwnerReferences {
if owner.Kind != "Service" {
continue
}
if printDetails {
ownerSection.WriteAttribute(owner.Kind, fmt.Sprintf("%s (%s)", owner.Name, owner.APIVersion))
dw.WriteAttribute(owner.Kind, fmt.Sprintf("%s (%s)", owner.Name, owner.APIVersion))
} else {
ownerSection.WriteAttribute(owner.Kind, owner.Name)
dw.WriteAttribute(owner.Kind, owner.Name)
}
}

}

func writeTraffic(dw printers.PrefixWriter, route *servingv1.Route) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/route/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestCompletion(t *testing.T) {
assert.Assert(t, action.Matches("get", "routes"))

assert.Check(t, util.ContainsAll(output,
"Name", "URL", "Owner References", "Traffic Targets", "Conditions",
"Name", "URL", "Traffic Targets", "Conditions",
"foo", "default", "90%", "foo-v2", "#v2", "10%", "@latest", "foo-v3"))
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewServiceDescribeCommand(p *commands.KnParams) *cobra.Command {

command := &cobra.Command{
Use: "describe NAME",
Short: "Show details for a given service",
Short: "Show details of a service",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("'kn service describe' requires name of the service as single argument")
Expand Down
4 changes: 2 additions & 2 deletions pkg/kn/commands/source/binding/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (
func NewBindingDescribeCommand(p *commands.KnParams) *cobra.Command {
cmd := &cobra.Command{
Use: "describe NAME",
Short: "Describe a sink binding.",
Short: "Show details of a sink binding",
Example: `
# Describe a sink binding with name 'mysinkbinding'
kn source binding describe mysinkbinding`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("'kn source binding describe' requires name of the source binding as single argument")
return errors.New("'kn source binding describe' requires name of the sink binding as single argument")
}
name := args[0]

Expand Down

0 comments on commit 3bf2396

Please sign in to comment.