render: Maintain a list of 'primary' api topologies for each report topology

This gives us a single source of truth in a variety of situations where we want to
know what view to direct a user to in order to 'open' a particular node.

I wanted to put this in app/api_topologies where the views are defined, but that creates
a circular import.
This commit is contained in:
Mike Lang
2017-04-10 14:30:52 -07:00
parent 75314cb910
commit 14ab5ccceb
+13
View File
@@ -81,6 +81,19 @@ var templates = map[string]struct{ Label, LabelMinor string }{
render.OutgoingInternetID: {render.OutboundMajor, render.OutboundMinor},
}
// 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.Container: "containers",
report.ContainerImage: "containers-by-image",
report.Pod: "pods",
report.ReplicaSet: "replica-sets",
report.Deployment: "deployments",
report.Service: "services",
report.ECSTask: "ecs-tasks",
report.ECSService: "ecs-services",
report.Host: "hosts",
}
// MakeNodeSummary summarizes a node, if possible.
func MakeNodeSummary(r report.Report, n report.Node) (NodeSummary, bool) {
if renderer, ok := renderers[n.Topology]; ok {