mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-17 20:41:51 +00:00
Sub-topolgies rendered in one place only
This commit is contained in:
@@ -23,15 +23,21 @@ type topologyStats struct {
|
||||
// makeTopologyList returns a handler that yields an APITopologyList.
|
||||
func makeTopologyList(rep Reporter) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
rpt := rep.Report()
|
||||
topologies := []APITopologyDesc{}
|
||||
var (
|
||||
rpt = rep.Report()
|
||||
topologies = []APITopologyDesc{}
|
||||
)
|
||||
for name, def := range topologyRegistry {
|
||||
if def.parent != "" {
|
||||
continue // subtopology, don't show at top level
|
||||
}
|
||||
subTopologies := []APITopologyDesc{}
|
||||
for subName, subDef := range topologyRegistry {
|
||||
if subDef.parent == name {
|
||||
subTopologies = append(subTopologies, APITopologyDesc{
|
||||
Name: subDef.human,
|
||||
URL: "/api/topology/" + subName,
|
||||
Name: subDef.human,
|
||||
URL: "/api/topology/" + subName,
|
||||
Stats: stats(render(rpt, subDef.maps)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestAPITopology(t *testing.T) {
|
||||
if err := json.Unmarshal(body, &topologies); err != nil {
|
||||
t.Fatalf("JSON parse error: %s", err)
|
||||
}
|
||||
equals(t, 5, len(topologies))
|
||||
equals(t, 3, len(topologies))
|
||||
|
||||
for _, topology := range topologies {
|
||||
is200(t, ts, topology.URL)
|
||||
|
||||
@@ -54,7 +54,7 @@ var topologyRegistry = map[string]topologyView{
|
||||
},
|
||||
},
|
||||
"applications-by-name": {
|
||||
human: "Applications by name",
|
||||
human: "by name",
|
||||
parent: "applications",
|
||||
maps: []topologyMapper{
|
||||
{report.SelectEndpoint, report.ProcessName, report.GenericGroupedPseudoNode},
|
||||
@@ -69,7 +69,7 @@ var topologyRegistry = map[string]topologyView{
|
||||
},
|
||||
},
|
||||
"containers-by-image": {
|
||||
human: "Containers by image",
|
||||
human: "by image",
|
||||
parent: "containers",
|
||||
maps: []topologyMapper{
|
||||
{report.SelectEndpoint, report.ProcessContainerImage, report.InternetOnlyPseudoNode},
|
||||
|
||||
Reference in New Issue
Block a user