11package cmd
22
33import (
4+ "encoding/json"
45 "fmt"
56 "os"
6- "strings"
77
88 "github.com/drycc/controller-sdk-go/api"
99 "github.com/drycc/controller-sdk-go/routes"
@@ -49,7 +49,7 @@ func (d *DryccCmd) RoutesList(appID string, results int) error {
4949 if count == 0 {
5050 d .Println (fmt .Sprintf ("No routes found in %s app." , appID ))
5151 } else {
52- table := d .getDefaultFormatTable ([]string {"NAME" , "OWNER" , "KIND" , "GATEWAY " , "SERVICE " })
52+ table := d .getDefaultFormatTable ([]string {"NAME" , "OWNER" , "KIND" , "GATEWAYS " , "SERVICES " })
5353 for _ , route := range routes {
5454 var services []string
5555 for _ , rule := range route .Rules {
@@ -65,13 +65,15 @@ func (d *DryccCmd) RoutesList(appID string, results int) error {
6565 for _ , gateway := range route .ParentRefs {
6666 gateways = append (gateways , fmt .Sprintf ("%s:%d" , gateway .Name , gateway .Port ))
6767 }
68- table .Append ([]string {
69- route .Name ,
70- route .Owner ,
71- route .Kind ,
72- safeGetString (strings .Join (gateways , "\n " )),
73- safeGetString (strings .Join (services , "\n " )),
74- })
68+ gatewaysBytes , err := json .Marshal (gateways )
69+ if err != nil {
70+ return err
71+ }
72+ servicesBytes , err := json .Marshal (services )
73+ if err != nil {
74+ return err
75+ }
76+ table .Append ([]string {route .Name , route .Owner , route .Kind , string (gatewaysBytes ), string (servicesBytes )})
7577 }
7678 table .Render ()
7779 }
0 commit comments