From 4349940f45d129ee6170e59d2e2a6a0b8b3215d8 Mon Sep 17 00:00:00 2001 From: Dmitriy Kalinin Date: Sat, 22 Feb 2020 15:51:16 -0500 Subject: [PATCH] print correct number of nodes in targetted cluster description --- pkg/kapp/cmd/core/deps_factory.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/kapp/cmd/core/deps_factory.go b/pkg/kapp/cmd/core/deps_factory.go index 6b7e6d3c2..ebcde83cf 100644 --- a/pkg/kapp/cmd/core/deps_factory.go +++ b/pkg/kapp/cmd/core/deps_factory.go @@ -88,21 +88,20 @@ func (f *DepsFactoryImpl) summarizeNodes(config *rest.Config) string { return "" } - if len(nodes.Items) == 0 { + switch len(nodes.Items) { + case 0: return "" - } - oldestNode := nodes.Items[0] - for _, node := range nodes.Items { - if node.CreationTimestamp.Before(&oldestNode.CreationTimestamp) { - oldestNode = node - } - } + case 1: + return nodes.Items[0].Name - desc := oldestNode.Name - if len(nodes.Items) > 1 { - desc += fmt.Sprintf(", %d+", len(nodes.Items)) + default: + oldestNode := nodes.Items[0] + for _, node := range nodes.Items { + if node.CreationTimestamp.Before(&oldestNode.CreationTimestamp) { + oldestNode = node + } + } + return fmt.Sprintf("%s, %d+", oldestNode.Name, len(nodes.Items)-1) } - - return desc }