weave.go 908 B

123456789101112131415161718192021222324252627282930313233343536
  1. package render
  2. import (
  3. "github.com/weaveworks/scope/report"
  4. )
  5. // WeaveRenderer is a Renderer which produces a renderable weave topology.
  6. //
  7. // not memoised
  8. var WeaveRenderer = MakeMap(
  9. MapWeaveIdentity,
  10. SelectOverlay,
  11. )
  12. // MapWeaveIdentity maps an overlay topology node to a weave topology node.
  13. func MapWeaveIdentity(m report.Node) report.Node {
  14. peerPrefix, _ := report.ParseOverlayNodeID(m.ID)
  15. if peerPrefix != report.WeaveOverlayPeerPrefix {
  16. return report.Node{}
  17. }
  18. var (
  19. node = m
  20. nickname, _ = m.Latest.Lookup(report.WeavePeerNickName)
  21. )
  22. // Nodes without a host id indicate they are not monitored by Scope
  23. // (their info doesn't come from a probe monitoring that peer directly)
  24. // , display them as pseudo nodes.
  25. if _, ok := node.Latest.Lookup(report.HostNodeID); !ok {
  26. id := MakePseudoNodeID(UnmanagedID, nickname)
  27. node = NewDerivedPseudoNode(id, m)
  28. }
  29. return node
  30. }