Skip to content

Commit

Permalink
optimize json output
Browse files Browse the repository at this point in the history
  • Loading branch information
DuodenumL committed Jul 18, 2022
1 parent c237e51 commit eb71152
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions describe/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ghodss/yaml"
"github.com/jedib0t/go-pretty/v6/table"

corepb "github.com/projecteru2/core/rpc/gen"
)

Expand Down Expand Up @@ -56,16 +57,20 @@ func describeAsJSON(o interface{}) {
}

func describeChNodeAsJSON(ch chan *corepb.Node) {
nodes := []*corepb.Node{}
for t := range ch {
j, _ := json.MarshalIndent(t, "", " ")
fmt.Println(string(j))
nodes = append(nodes, t)
}
j, _ := json.MarshalIndent(nodes, "", " ")
fmt.Println(string(j))
}
func describeChNodeResourceAsJSON(ch chan *corepb.NodeResource) {
nodes := []*corepb.NodeResource{}
for t := range ch {
j, _ := json.MarshalIndent(t, "", " ")
fmt.Println(string(j))
nodes = append(nodes, t)
}
j, _ := json.MarshalIndent(nodes, "", " ")
fmt.Println(string(j))
}

func describeAsYAML(o interface{}) {
Expand Down

0 comments on commit eb71152

Please sign in to comment.