Fix Toggle Faults filtering (#2509)
* Added valid column to workloads for toast filtering * Removed redundant status func call, changed workload header ordermine
parent
3c20f0d5a1
commit
cd5522cd35
|
|
@ -122,12 +122,14 @@ func (a *Workload) List(ctx context.Context, ns string) ([]runtime.Object, error
|
||||||
ts = m.CreationTimestamp
|
ts = m.CreationTimestamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stat := status(gvr, r, table.ColumnDefinitions)
|
||||||
oo = append(oo, &render.WorkloadRes{Row: metav1.TableRow{Cells: []interface{}{
|
oo = append(oo, &render.WorkloadRes{Row: metav1.TableRow{Cells: []interface{}{
|
||||||
gvr.String(),
|
gvr.String(),
|
||||||
ns,
|
ns,
|
||||||
r.Cells[indexOf("Name", table.ColumnDefinitions)],
|
r.Cells[indexOf("Name", table.ColumnDefinitions)],
|
||||||
diagnose(gvr, r, table.ColumnDefinitions),
|
stat,
|
||||||
status(gvr, r, table.ColumnDefinitions),
|
readiness(gvr, r, table.ColumnDefinitions),
|
||||||
|
validity(stat),
|
||||||
ts,
|
ts,
|
||||||
}}})
|
}}})
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +140,7 @@ func (a *Workload) List(ctx context.Context, ns string) ([]runtime.Object, error
|
||||||
|
|
||||||
// Helpers...
|
// 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 {
|
switch gvr {
|
||||||
case PodGVR, DpGVR, StsGVR:
|
case PodGVR, DpGVR, StsGVR:
|
||||||
return r.Cells[indexOf("Ready", h)].(string)
|
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
|
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 {
|
switch gvr {
|
||||||
case PodGVR:
|
case PodGVR:
|
||||||
if !isReady(r.Cells[indexOf("Ready", h)].(string)) || r.Cells[indexOf("Status", h)] != render.PhaseRunning {
|
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
|
return StatusOK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validity(status string) string {
|
||||||
|
if status != "DEGRADED" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
func isReady(s string) bool {
|
func isReady(s string) bool {
|
||||||
tt := strings.Split(s, "/")
|
tt := strings.Split(s, "/")
|
||||||
if len(tt) != 2 {
|
if len(tt) != 2 {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ func (Workload) Header(string) Header {
|
||||||
HeaderColumn{Name: "NAME"},
|
HeaderColumn{Name: "NAME"},
|
||||||
HeaderColumn{Name: "STATUS"},
|
HeaderColumn{Name: "STATUS"},
|
||||||
HeaderColumn{Name: "READY"},
|
HeaderColumn{Name: "READY"},
|
||||||
|
HeaderColumn{Name: "VALID", Wide: true},
|
||||||
HeaderColumn{Name: "AGE", Time: 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[2].(string),
|
||||||
res.Row.Cells[3].(string),
|
res.Row.Cells[3].(string),
|
||||||
res.Row.Cells[4].(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
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue