render: In minor labels, display '0 things' instead of blank if zero things present

This also fixes a bug where k8s controller nodes would show up as 'Deployment of' without any number
This commit is contained in:
Mike Lang
2017-07-18 11:44:51 -07:00
parent 57f2e6a083
commit ac96738ad0

View File

@@ -344,13 +344,14 @@ func groupNodeSummary(base NodeSummary, r report.Report, n report.Node) (NodeSum
}
func pluralize(counters report.Counters, key, singular, plural string) string {
if c, ok := counters.Lookup(key); ok {
if c == 1 {
return fmt.Sprintf("%d %s", c, singular)
}
return fmt.Sprintf("%d %s", c, plural)
c, ok := counters.Lookup(key)
if !ok {
c = 0
}
return ""
if c == 1 {
return fmt.Sprintf("%d %s", c, singular)
}
return fmt.Sprintf("%d %s", c, plural)
}
type nodeSummariesByID []NodeSummary