Skip to content

Commit

Permalink
Remove explicit listing of api topologies in render/detailed/node specs
Browse files Browse the repository at this point in the history
Instead, we can infer them from the render topology and the primaryAPITopology map
  • Loading branch information
ekimekim committed Apr 10, 2017
1 parent 7ba3555 commit 9f0f120
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
48 changes: 23 additions & 25 deletions render/detailed/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ var (
{
topologyID: report.Host,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "hosts",
Label: "Hosts",
Label: "Hosts",
Columns: []Column{
{ID: host.CPUUsage, Label: "CPU", Datatype: "number"},
{ID: host.MemoryUsage, Label: "Memory", Datatype: "number"},
Expand All @@ -145,8 +144,7 @@ var (
{
topologyID: report.Service,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "services",
Label: "Services",
Label: "Services",
Columns: []Column{
{ID: report.Pod, Label: "# Pods", Datatype: "number"},
{ID: kubernetes.IP, Label: "IP", Datatype: "ip"},
Expand All @@ -156,8 +154,7 @@ var (
{
topologyID: report.ReplicaSet,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "replica-sets",
Label: "Replica Sets",
Label: "Replica Sets",
Columns: []Column{
{ID: report.Pod, Label: "# Pods", Datatype: "number"},
{ID: kubernetes.ObservedGeneration, Label: "Observed Gen.", Datatype: "number"},
Expand All @@ -167,8 +164,7 @@ var (
{
topologyID: report.Pod,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "pods",
Label: "Pods",
Label: "Pods",

Columns: []Column{
{ID: kubernetes.State, Label: "State"},
Expand All @@ -180,8 +176,7 @@ var (
{
topologyID: report.ECSService,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "ecs-services",
Label: "Services",
Label: "Services",
Columns: []Column{
{ID: awsecs.ServiceRunningCount, Label: "Running", Datatype: "number"},
{ID: awsecs.ServiceDesiredCount, Label: "Desired", Datatype: "number"},
Expand All @@ -191,8 +186,7 @@ var (
{
topologyID: report.ECSTask,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "ecs-tasks",
Label: "Tasks",
Label: "Tasks",
Columns: []Column{
{ID: awsecs.CreatedAt, Label: "Created At", Datatype: "datetime"},
},
Expand All @@ -201,8 +195,7 @@ var (
{
topologyID: report.Container,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "containers",
Label: "Containers", Columns: []Column{
Label: "Containers", Columns: []Column{
{ID: docker.CPUTotalUsage, Label: "CPU", Datatype: "number"},
{ID: docker.MemoryUsage, Label: "Memory", Datatype: "number"},
},
Expand All @@ -211,8 +204,7 @@ var (
{
topologyID: report.Process,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "processes",
Label: "Processes", Columns: []Column{
Label: "Processes", Columns: []Column{
{ID: process.PID, Label: "PID", Datatype: "number"},
{ID: process.CPUUsage, Label: "CPU", Datatype: "number"},
{ID: process.MemoryUsage, Label: "Memory", Datatype: "number"},
Expand Down Expand Up @@ -248,13 +240,19 @@ func children(r report.Report, n report.Node) []NodeSummaryGroup {
nodeSummaryGroups := []NodeSummaryGroup{}
// Apply specific group specs in the order they're listed
for _, spec := range nodeSummaryGroupSpecs {
if len(summaries[spec.topologyID]) > 0 {
sort.Sort(nodeSummariesByID(summaries[spec.TopologyID]))
group := spec.NodeSummaryGroup
group.Nodes = summaries[spec.topologyID]
nodeSummaryGroups = append(nodeSummaryGroups, group)
delete(summaries, spec.topologyID)
if len(summaries[spec.topologyID]) == 0 {
continue
}
apiTopology, ok := primaryAPITopology[spec.topologyID]
if !ok {
continue
}
sort.Sort(nodeSummariesByID(summaries[spec.topologyID]))
group := spec.NodeSummaryGroup
group.Nodes = summaries[spec.topologyID]
group.TopologyID = apiTopology
nodeSummaryGroups = append(nodeSummaryGroups, group)
delete(summaries, spec.topologyID)
}
// As a fallback, in case a topology has no group spec defined, add any remaining at the end
for topologyID, nodeSummaries := range summaries {
Expand All @@ -271,9 +269,9 @@ func children(r report.Report, n report.Node) []NodeSummaryGroup {
}
sort.Sort(nodeSummariesByID(nodeSummaries))
group := NodeSummaryGroup{
ID: apiTopology,
Label: topology.LabelPlural,
Columns: []Column{},
TopologyID: apiTopology,
Label: topology.LabelPlural,
Columns: []Column{},
}
nodeSummaryGroups = append(nodeSummaryGroups, group)
}
Expand Down
1 change: 1 addition & 0 deletions render/detailed/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var templates = map[string]struct{ Label, LabelMinor string }{

// For each report.Topology, map to a 'primary' API topology. This can then be used in a variety of places.
var primaryAPITopology = map[string]string{
report.Process: "processes",
report.Container: "containers",
report.ContainerImage: "containers-by-image",
report.Pod: "pods",
Expand Down

0 comments on commit 9f0f120

Please sign in to comment.