Skip to content

Commit

Permalink
Merge pull request #20 from openinfradev/add_filter_condition
Browse files Browse the repository at this point in the history
feature. add filter to cluster list
  • Loading branch information
Jaesang authored Mar 28, 2022
2 parents 46fd25a + d485a2d commit 7ca9de8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 13 additions & 2 deletions cmd/cluster_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ tks cluster list (--long)`,
if err != nil {
fmt.Println(err)
} else {
printClusters(r, long)
printClusters(filterResponse(r), long)
}
},
}
Expand All @@ -94,7 +94,6 @@ func init() {
}

func printClusters(r *pb.GetClustersResponse, long bool) {
fmt.Println(r.Clusters[0].Name)
t := table.NewWriter()
tTemp := table.Table{}
tTemp.Render()
Expand Down Expand Up @@ -126,3 +125,15 @@ func parseTime(t *timestamppb.Timestamp) string {

return t.AsTime().Format("2006-01-02 15:04:05")
}

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

r.Clusters = clusters
return r
}
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ require (
github.com/jedib0t/go-pretty v4.3.0+incompatible
github.com/matryer/is v1.4.0
github.com/openinfradev/tks-contract v0.1.1-0.20210928021110-fe2b666327cc
github.com/openinfradev/tks-proto v0.0.6-0.20220318062944-7fccd257bcae
github.com/openinfradev/tks-proto v0.0.6-0.20220324075944-e471af2c8c49
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,8 @@ github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWEr
github.com/openinfradev/tks-contract v0.1.1-0.20210928021110-fe2b666327cc h1:CwlJuBCGJqCA11SVEk/Qdtp5n1KRJPZweXESd+C/NQ0=
github.com/openinfradev/tks-contract v0.1.1-0.20210928021110-fe2b666327cc/go.mod h1:Fs/fid/nEajtBWS068Vi0IDKFbBSiL4OWu9L1J124Rc=
github.com/openinfradev/tks-proto v0.0.6-0.20210924020717-178698d59e9d/go.mod h1:WDzIQ7ayHVA7cA3Z+D2etK7gQuo4penewcC/cWcewlA=
github.com/openinfradev/tks-proto v0.0.6-0.20211015003551-ed8f9541f40d h1:ypM1LN+7tjRGzmTBNVegY/25KhJLFuQor2/+DfuhxDM=
github.com/openinfradev/tks-proto v0.0.6-0.20211015003551-ed8f9541f40d/go.mod h1:ul6kvgOXhNQvXEUmb92Wh5BmsuzknnTCb3wqmVNd/iI=
github.com/openinfradev/tks-proto v0.0.6-0.20220318062944-7fccd257bcae h1:n4VlqbtNhQ36WMrqHCWkHp7PR5qUr3AVDdOBINZoa5o=
github.com/openinfradev/tks-proto v0.0.6-0.20220318062944-7fccd257bcae/go.mod h1:3DrATRNCUJMW0oMLHT6D1teN4hX0vMGH4qOGnadakmo=
github.com/openinfradev/tks-proto v0.0.6-0.20220324075944-e471af2c8c49 h1:XYNl9fXGUH02/Laqht+ba2FmgOXrl7sUDHcAZHsSaUE=
github.com/openinfradev/tks-proto v0.0.6-0.20220324075944-e471af2c8c49/go.mod h1:3DrATRNCUJMW0oMLHT6D1teN4hX0vMGH4qOGnadakmo=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down

0 comments on commit 7ca9de8

Please sign in to comment.