mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Add Prune method (née Sterilize)
This commit is contained in:
@@ -122,6 +122,17 @@ func (rn RenderableNode) Copy() RenderableNode {
|
||||
}
|
||||
}
|
||||
|
||||
// Prune returns a copy of the RenderableNode with all information not
|
||||
// strictly necessary for rendering nodes and edges stripped away.
|
||||
// Specifically, that means cutting out parts of the Node.
|
||||
func (rn RenderableNode) Prune() RenderableNode {
|
||||
cp := rn.Copy()
|
||||
cp.Node.Metadata = report.Metadata{} // snip
|
||||
cp.Node.Counters = report.Counters{} // snip
|
||||
cp.Node.Edges = report.EdgeMetadatas{} // snip
|
||||
return cp
|
||||
}
|
||||
|
||||
// RenderableNodes is a set of RenderableNodes
|
||||
type RenderableNodes map[string]RenderableNode
|
||||
|
||||
@@ -149,3 +160,13 @@ func (rns RenderableNodes) Merge(other RenderableNodes) RenderableNodes {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Prune returns a copy of the RenderableNodes with all information not
|
||||
// strictly necessary for rendering nodes and edges in the UI cut away.
|
||||
func (rns RenderableNodes) Prune() RenderableNodes {
|
||||
cp := rns.Copy()
|
||||
for id, rn := range cp {
|
||||
cp[id] = rn.Prune()
|
||||
}
|
||||
return cp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user