MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / getWorkerPoolAsBasic

Function getWorkerPoolAsBasic

pkg/cmd/workerpool/view/view.go:129–177  ·  view source on GitHub ↗
(opts *shared.ViewOptions, workerPool workerpools.IWorkerPool)

Source from the content-addressed store, hash-verified

127}
128
129func getWorkerPoolAsBasic(opts *shared.ViewOptions, workerPool workerpools.IWorkerPool) string {
130 var result strings.Builder
131
132 // Header
133 result.WriteString(fmt.Sprintf("%s %s\n", output.Bold(workerPool.GetName()), output.Dimf("(%s)", workerPool.GetID())))
134 result.WriteString(fmt.Sprintf("Worker Pool Type: %s\n", string(workerPool.GetWorkerPoolType())))
135
136 if workerPool.GetIsDefault() {
137 result.WriteString(fmt.Sprintf("Default: %s\n", output.Green("Yes")))
138 }
139
140 // Worker statistics
141 workers, _ := getWorkers(opts, workerPool)
142 workerStats := calculateWorkerStats(workers)
143
144 result.WriteString(fmt.Sprintf("Total workers: %d\n", workerStats.Total))
145 if workerStats.Disabled > 0 {
146 result.WriteString(fmt.Sprintf("Disabled workers: %s\n", output.Dimf("%d", workerStats.Disabled)))
147 }
148 if workerStats.Healthy > 0 {
149 result.WriteString(fmt.Sprintf("Healthy workers: %s\n", output.Greenf("%d", workerStats.Healthy)))
150 }
151 if workerStats.HasWarnings > 0 {
152 result.WriteString(fmt.Sprintf("Has Warnings workers: %s\n", output.Yellowf("%d", workerStats.HasWarnings)))
153 }
154 if workerStats.Unhealthy > 0 {
155 result.WriteString(fmt.Sprintf("Unhealthy workers: %s\n", output.Redf("%d", workerStats.Unhealthy)))
156 }
157 if workerStats.Unavailable > 0 {
158 result.WriteString(fmt.Sprintf("Unavailable workers: %s\n", output.Redf("%d", workerStats.Unavailable)))
159 }
160
161 // Worker type breakdown
162 if workerStats.SSH > 0 {
163 result.WriteString(fmt.Sprintf("SSH workers: %d\n", workerStats.SSH))
164 }
165 if workerStats.ListeningTentacle > 0 {
166 result.WriteString(fmt.Sprintf("Listening Tentacle workers: %d\n", workerStats.ListeningTentacle))
167 }
168 if workerStats.PollingTentacle > 0 {
169 result.WriteString(fmt.Sprintf("Polling Tentacle workers: %d\n", workerStats.PollingTentacle))
170 }
171
172 // Web URL
173 url := util.GenerateWebURL(opts.Host, workerPool.GetSpaceID(), fmt.Sprintf("infrastructure/workerpools/%s", workerPool.GetID()))
174 result.WriteString(fmt.Sprintf("\nView this worker pool in Octopus Deploy: %s\n", output.Blue(url)))
175
176 return result.String()
177}
178
179func getWorkers(opts *shared.ViewOptions, workerPool workerpools.IWorkerPool) ([]*machines.Worker, error) {
180 if workerPool.GetWorkerPoolType() == workerpools.WorkerPoolTypeStatic {

Callers 1

ViewRunFunction · 0.85

Calls 11

BoldFunction · 0.92
DimfFunction · 0.92
GreenFunction · 0.92
GreenfFunction · 0.92
YellowfFunction · 0.92
RedfFunction · 0.92
GenerateWebURLFunction · 0.92
BlueFunction · 0.92
getWorkersFunction · 0.85
calculateWorkerStatsFunction · 0.85
GetNameMethod · 0.65

Tested by

no test coverage detected