From ac96738ad016146453350c91e82f4b2ba37002a9 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Tue, 18 Jul 2017 11:44:51 -0700 Subject: [PATCH] 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 --- render/detailed/summary.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/render/detailed/summary.go b/render/detailed/summary.go index 2ef25f264..ae5834d65 100644 --- a/render/detailed/summary.go +++ b/render/detailed/summary.go @@ -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