1
0
mirror of https://github.com/rancher/cli.git synced 2026-02-05 09:48:36 +01:00

Update cluster list to use nodeCount field

This commit is contained in:
Dan Ramich
2020-04-06 13:48:26 -07:00
parent 5a76c7249e
commit 160b14c16c

View File

@@ -29,7 +29,7 @@ type ClusterData struct {
Cluster managementClient.Cluster
Name string
Provider string
Nodes int
Nodes int64
CPU string
RAM string
Pods string
@@ -229,10 +229,6 @@ func clusterLs(ctx *cli.Context) error {
if item.ID == c.UserConfig.FocusedCluster() {
current = "*"
}
nodeCount, err := getClusterNodeCount(ctx, c, item.ID)
if err != nil {
logrus.Errorf("error getting cluster node count for cluster %s: %s", item.Name, err)
}
writer.Write(&ClusterData{
ID: item.ID,
@@ -240,7 +236,7 @@ func clusterLs(ctx *cli.Context) error {
Cluster: item,
Name: getClusterName(&item),
Provider: getClusterProvider(item),
Nodes: nodeCount,
Nodes: item.NodeCount,
CPU: getClusterCPU(item),
RAM: getClusterRAM(item),
Pods: getClusterPods(item),
@@ -699,14 +695,6 @@ func getClusterProvider(cluster managementClient.Cluster) string {
}
}
func getClusterNodeCount(ctx *cli.Context, c *cliclient.MasterClient, clusterID string) (int, error) {
nodes, err := getNodesList(ctx, c, clusterID)
if err != nil {
return 0, err
}
return len(nodes.Data), nil
}
func getClusterCPU(cluster managementClient.Cluster) string {
req := parseResourceString(cluster.Requested["cpu"])
alloc := parseResourceString(cluster.Allocatable["cpu"])