Skip to content

Commit

Permalink
print correct number of nodes in targetted cluster description
Browse files Browse the repository at this point in the history
  • Loading branch information
cppforlife committed Feb 22, 2020
1 parent afdf642 commit 4349940
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions pkg/kapp/cmd/core/deps_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 4349940

Please sign in to comment.