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()
|
defer tabwriter.Flush()
|
||||||
|
|
||||||
if !flags.noHeader {
|
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 {
|
if flags.token {
|
||||||
headers = append(headers, "TOKEN")
|
headers = append(headers, "TOKEN")
|
||||||
}
|
}
|
||||||
@ -118,11 +118,12 @@ func PrintClusters(clusters []*k3d.Cluster, flags clusterFlags) {
|
|||||||
for _, cluster := range clusters {
|
for _, cluster := range clusters {
|
||||||
serverCount := cluster.ServerCount()
|
serverCount := cluster.ServerCount()
|
||||||
agentCount := cluster.AgentCount()
|
agentCount := cluster.AgentCount()
|
||||||
|
hasLB := cluster.HasLoadBalancer()
|
||||||
|
|
||||||
if flags.token {
|
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 {
|
} 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
|
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
|
// Node describes a k3d node
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Name string `yaml:"name" json:"name,omitempty"`
|
Name string `yaml:"name" json:"name,omitempty"`
|
||||||
|
Loading…
Reference in New Issue
Block a user