@@ -55,13 +55,14 @@ type Waitables struct {
5555}
5656
5757func (w * Waitables ) AddItem (kind string , namespace string , name string ) error {
58- if kind == "pod" {
58+ switch kind {
59+ case "pod" :
5960 w .addPod (namespace , name )
60- } else if kind == "job" {
61+ case "job" :
6162 w .addJob (namespace , name )
62- } else if kind == "service" {
63+ case "service" :
6364 w .addService (namespace , name )
64- } else {
65+ default :
6566 return fmt .Errorf ("unsupported kind '%s'" , kind )
6667 }
6768 return nil
@@ -180,21 +181,31 @@ func (w *Waitables) getStatusTreeString() string {
180181 status := "Unavailable"
181182 svcIsAvailable := (! w .onlyOnePerServiceRequired && val .IsAvailable ()) || (w .onlyOnePerServiceRequired && val .IsAtLeastOneAvailable ())
182183 if svcIsAvailable {
183- status = "Available"
184+ if val .IsExternal () {
185+ status = "External"
186+ } else {
187+ status = "Available"
188+ }
184189 }
185- svc_branch := branch .AddMetaBranch (TreeStatusUnknown , fmt .Sprintf ("service/%s: %s" , n , status ))
186-
187- for podname , pod := range * val .GetChildren () {
188- status := "NotReady"
189- meta := TreeStatusNotDone
190- if pod .IsReady () {
191- status = "Ready"
192- meta = TreeStatusDone
193- } else if w .onlyOnePerServiceRequired && svcIsAvailable {
194- status = "Ignored"
195- meta = TreeStatusIgnored
190+ var svc_branch treeprint.Tree
191+
192+ if val .IsExternal () {
193+ svc_branch = branch .AddMetaBranch (TreeStatusDone , fmt .Sprintf ("service/%s: %s" , n , status ))
194+ } else {
195+ svc_branch = branch .AddMetaBranch (TreeStatusUnknown , fmt .Sprintf ("service/%s: %s" , n , status ))
196+
197+ for podname , pod := range * val .GetChildren () {
198+ status := "NotReady"
199+ meta := TreeStatusNotDone
200+ if pod .IsReady () {
201+ status = "Ready"
202+ meta = TreeStatusDone
203+ } else if w .onlyOnePerServiceRequired && svcIsAvailable {
204+ status = "Ignored"
205+ meta = TreeStatusIgnored
206+ }
207+ svc_branch .AddMetaNode (meta , fmt .Sprintf ("pod/%s: %s" , podname , status ))
196208 }
197- svc_branch .AddMetaNode (meta , fmt .Sprintf ("pod/%s: %s" , podname , status ))
198209 }
199210 }
200211 }
@@ -264,6 +275,10 @@ func (w *Waitables) SetServiceChildren(meta *metav1.ObjectMeta, pods []corev1.Po
264275 w.Services [meta.Namespace ][meta.Name ].WithChildren (podItems )
265276}
266277
278+ func (w * Waitables ) SetServiceExternality (meta * metav1.ObjectMeta , isExternal bool ) {
279+ w.Services [meta.Namespace ][meta.Name ].WithExternal (isExternal )
280+ }
281+
267282func (w * Waitables ) TotalCount () int {
268283 return w .Services .TotalCount () + w .Pods .TotalCount () + w .Jobs .TotalCount ()
269284}
0 commit comments