Skip to content

Commit

Permalink
handle case that GetClusters returns empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
robertchoi80 committed Apr 4, 2022
1 parent 7ca9de8 commit a3fb600
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/cluster_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ tks cluster list (--long)`,
if err != nil {
fmt.Println(err)
} else {
printClusters(filterResponse(r), long)
if len(r.Clusters) == 0 {
fmt.Println("No cluster exists for specified contract!")
} else {
printClusters(filterResponse(r), long)
}
}
},
}
Expand Down Expand Up @@ -127,7 +131,7 @@ func parseTime(t *timestamppb.Timestamp) string {
}

func filterResponse(r *pb.GetClustersResponse) *pb.GetClustersResponse {
clusters := []*pb.Cluster {}
clusters := []*pb.Cluster{}
for _, cluster := range r.Clusters {
if cluster.GetStatus() != pb.ClusterStatus_DELETED {
clusters = append(clusters, cluster)
Expand Down

0 comments on commit a3fb600

Please sign in to comment.