Skip to content

Commit

Permalink
Fix client compability (#359)
Browse files Browse the repository at this point in the history
* fix client compability

* follow comments
  • Loading branch information
typhoonzero committed Aug 29, 2017
1 parent 95a2e2d commit 95fedf5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions go/paddlecloud/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,19 @@ func jobs() error {
if err != nil {
return err
}
items := respObj.(map[string]interface{})["items"].([]interface{})
terminatingJobs := respObj.(map[string]interface{})["terminating"].([]interface{})
itemsRaw, ok := respObj.(map[string]interface{})["items"]
if !ok {
// nothing to print
return nil
}
items := itemsRaw.([]interface{})
// NOTE: terminating section may not exist
var termJobs []interface{}
if termJobsRaw, ok := respObj.(map[string]interface{})["terminating"]; ok {
termJobs = termJobsRaw.([]interface{})
} else {
termJobs = []interface{}{}
}

w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
if len(items) >= 0 {
Expand Down Expand Up @@ -201,7 +212,7 @@ func jobs() error {
readyReplicas, replicas)
}

for _, t := range terminatingJobs {
for _, t := range termJobs {
fmt.Fprintf(w, "%s\t%s\t%v\t%v\t%v\t%v\t%v\t%v\t\n",
t,
"Terminating",
Expand Down

0 comments on commit 95fedf5

Please sign in to comment.