mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
refactor: dedup pod group summary functions
This commit is contained in:
@@ -65,9 +65,9 @@ func MakeNodeSummary(r report.Report, n report.Node) (NodeSummary, bool) {
|
||||
report.Container: containerNodeSummary,
|
||||
report.ContainerImage: containerImageNodeSummary,
|
||||
report.Pod: podNodeSummary,
|
||||
report.Service: serviceNodeSummary,
|
||||
report.Deployment: deploymentNodeSummary,
|
||||
report.ReplicaSet: replicaSetNodeSummary,
|
||||
report.Service: podGroupNodeSummary,
|
||||
report.Deployment: podGroupNodeSummary,
|
||||
report.ReplicaSet: podGroupNodeSummary,
|
||||
report.Host: hostNodeSummary,
|
||||
}
|
||||
if renderer, ok := renderers[n.Topology]; ok {
|
||||
@@ -225,42 +225,11 @@ func podNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
return base, true
|
||||
}
|
||||
|
||||
func serviceNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
base = addKubernetesLabelAndRank(base, n)
|
||||
base.Stack = true
|
||||
|
||||
// Services are always just a group of pods, so there's no counting multiple
|
||||
// services which might be grouped together.
|
||||
if p, ok := n.Counters.Lookup(report.Pod); ok {
|
||||
if p == 1 {
|
||||
base.LabelMinor = fmt.Sprintf("%d pod", p)
|
||||
} else {
|
||||
base.LabelMinor = fmt.Sprintf("%d pods", p)
|
||||
}
|
||||
}
|
||||
|
||||
return base, true
|
||||
}
|
||||
|
||||
func deploymentNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
base = addKubernetesLabelAndRank(base, n)
|
||||
base.Stack = true
|
||||
|
||||
if p, ok := n.Counters.Lookup(report.Pod); ok {
|
||||
if p == 1 {
|
||||
base.LabelMinor = fmt.Sprintf("%d pod", p)
|
||||
} else {
|
||||
base.LabelMinor = fmt.Sprintf("%d pods", p)
|
||||
}
|
||||
}
|
||||
|
||||
return base, true
|
||||
}
|
||||
|
||||
func replicaSetNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
func podGroupNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
|
||||
base = addKubernetesLabelAndRank(base, n)
|
||||
base.Stack = true
|
||||
|
||||
// NB: pods are the highest aggregation level for which we display counts.
|
||||
if p, ok := n.Counters.Lookup(report.Pod); ok {
|
||||
if p == 1 {
|
||||
base.LabelMinor = fmt.Sprintf("%d pod", p)
|
||||
|
||||
Reference in New Issue
Block a user