selectors.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package render
  2. import (
  3. "context"
  4. "github.com/weaveworks/scope/report"
  5. )
  6. // TopologySelector selects a single topology from a report.
  7. // NB it is also a Renderer!
  8. type TopologySelector string
  9. // Render implements Renderer
  10. func (t TopologySelector) Render(ctx context.Context, r report.Report) Nodes {
  11. topology, _ := r.Topology(string(t))
  12. return Nodes{Nodes: topology.Nodes}
  13. }
  14. // The topology selectors implement a Renderer which fetch the nodes from the
  15. // various report topologies.
  16. var (
  17. SelectEndpoint = TopologySelector(report.Endpoint)
  18. SelectProcess = TopologySelector(report.Process)
  19. SelectContainer = TopologySelector(report.Container)
  20. SelectContainerImage = TopologySelector(report.ContainerImage)
  21. SelectHost = TopologySelector(report.Host)
  22. SelectPod = TopologySelector(report.Pod)
  23. SelectService = TopologySelector(report.Service)
  24. SelectDeployment = TopologySelector(report.Deployment)
  25. SelectDaemonSet = TopologySelector(report.DaemonSet)
  26. SelectStatefulSet = TopologySelector(report.StatefulSet)
  27. SelectCronJob = TopologySelector(report.CronJob)
  28. SelectJob = TopologySelector(report.Job)
  29. SelectECSTask = TopologySelector(report.ECSTask)
  30. SelectECSService = TopologySelector(report.ECSService)
  31. SelectSwarmService = TopologySelector(report.SwarmService)
  32. SelectOverlay = TopologySelector(report.Overlay)
  33. SelectPersistentVolume = TopologySelector(report.PersistentVolume)
  34. SelectPersistentVolumeClaim = TopologySelector(report.PersistentVolumeClaim)
  35. SelectStorageClass = TopologySelector(report.StorageClass)
  36. SelectVolumeSnapshot = TopologySelector(report.VolumeSnapshot)
  37. SelectVolumeSnapshotData = TopologySelector(report.VolumeSnapshotData)
  38. )