diff --git a/internal/dao/workload.go b/internal/dao/workload.go index ae9693b831..72027605ce 100644 --- a/internal/dao/workload.go +++ b/internal/dao/workload.go @@ -122,12 +122,14 @@ func (a *Workload) List(ctx context.Context, ns string) ([]runtime.Object, error ts = m.CreationTimestamp } } + stat := status(gvr, r, table.ColumnDefinitions) oo = append(oo, &render.WorkloadRes{Row: metav1.TableRow{Cells: []interface{}{ gvr.String(), ns, r.Cells[indexOf("Name", table.ColumnDefinitions)], - diagnose(gvr, r, table.ColumnDefinitions), - status(gvr, r, table.ColumnDefinitions), + stat, + readiness(gvr, r, table.ColumnDefinitions), + validity(stat), ts, }}}) } @@ -138,7 +140,7 @@ func (a *Workload) List(ctx context.Context, ns string) ([]runtime.Object, error // Helpers... -func status(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string { +func readiness(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string { switch gvr { case PodGVR, DpGVR, StsGVR: return r.Cells[indexOf("Ready", h)].(string) @@ -153,7 +155,7 @@ func status(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) return render.NAValue } -func diagnose(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string { +func status(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinition) string { switch gvr { case PodGVR: if !isReady(r.Cells[indexOf("Ready", h)].(string)) || r.Cells[indexOf("Status", h)] != render.PhaseRunning { @@ -187,6 +189,14 @@ func diagnose(gvr client.GVR, r metav1.TableRow, h []metav1.TableColumnDefinitio return StatusOK } +func validity(status string) string { + if status != "DEGRADED" { + return "" + } + + return status +} + func isReady(s string) bool { tt := strings.Split(s, "/") if len(tt) != 2 { diff --git a/internal/render/workload.go b/internal/render/workload.go index 058cfd4078..250c52ecff 100644 --- a/internal/render/workload.go +++ b/internal/render/workload.go @@ -44,6 +44,7 @@ func (Workload) Header(string) Header { HeaderColumn{Name: "NAME"}, HeaderColumn{Name: "STATUS"}, HeaderColumn{Name: "READY"}, + HeaderColumn{Name: "VALID", Wide: true}, HeaderColumn{Name: "AGE", Time: true}, } } @@ -62,7 +63,8 @@ func (n Workload) Render(o interface{}, _ string, r *Row) error { res.Row.Cells[2].(string), res.Row.Cells[3].(string), res.Row.Cells[4].(string), - ToAge(res.Row.Cells[5].(metav1.Time)), + res.Row.Cells[5].(string), + ToAge(res.Row.Cells[6].(metav1.Time)), } return nil