clusterList: add bool for loadbalancer
This commit is contained in:
parent
92547b11d4
commit
e5d093d3ce
@ -103,7 +103,7 @@ func PrintClusters(clusters []*k3d.Cluster, flags clusterFlags) {
|
||||
defer tabwriter.Flush()
|
||||
|
||||
if !flags.noHeader {
|
||||
headers := []string{"NAME", "SERVERS", "AGENTS"} // TODO: getCluster: add status column
|
||||
headers := []string{"NAME", "SERVERS", "AGENTS", "LOADBALANCER"} // TODO: getCluster: add status column
|
||||
if flags.token {
|
||||
headers = append(headers, "TOKEN")
|
||||
}
|
||||
@ -118,11 +118,12 @@ func PrintClusters(clusters []*k3d.Cluster, flags clusterFlags) {
|
||||
for _, cluster := range clusters {
|
||||
serverCount := cluster.ServerCount()
|
||||
agentCount := cluster.AgentCount()
|
||||
hasLB := cluster.HasLoadBalancer()
|
||||
|
||||
if flags.token {
|
||||
fmt.Fprintf(tabwriter, "%s\t%d\t%d\t%s\n", cluster.Name, serverCount, agentCount, cluster.Token)
|
||||
fmt.Fprintf(tabwriter, "%s\t%d\t%d\t%t\t%s\n", cluster.Name, serverCount, agentCount, hasLB, cluster.Token)
|
||||
} else {
|
||||
fmt.Fprintf(tabwriter, "%s\t%d\t%d\n", cluster.Name, serverCount, agentCount)
|
||||
fmt.Fprintf(tabwriter, "%s\t%d\t%d\t%t\n", cluster.Name, serverCount, agentCount, hasLB)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +203,16 @@ func (c *Cluster) AgentCount() int {
|
||||
return agentCount
|
||||
}
|
||||
|
||||
// HasLoadBalancer returns true if cluster has a loadbalancer node
|
||||
func (c *Cluster) HasLoadBalancer() bool {
|
||||
for _, node := range c.Nodes {
|
||||
if node.Role == LoadBalancerRole {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Node describes a k3d node
|
||||
type Node struct {
|
||||
Name string `yaml:"name" json:"name,omitempty"`
|
||||
|
Loading…
Reference in New Issue
Block a user