mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +00:00
Refactor: extract pseudoNodeID function
This commit is contained in:
15
render/id.go
15
render/id.go
@@ -45,6 +45,21 @@ func NewDerivedExternalNode(n report.Node, addr string, local report.Networks) (
|
||||
return NewDerivedPseudoNode(id, n), true
|
||||
}
|
||||
|
||||
func pseudoNodeID(n report.Node, local report.Networks) (string, bool) {
|
||||
_, addr, _, ok := report.ParseEndpointNodeID(n.ID)
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
|
||||
if id, ok := externalNodeID(n, addr, local); ok {
|
||||
return id, ok
|
||||
}
|
||||
|
||||
// due to https://github.com/weaveworks/scope/issues/1323 we are dropping
|
||||
// all non-external pseudo nodes for now.
|
||||
return "", false
|
||||
}
|
||||
|
||||
// figure out if a node should be considered external and returns an ID which can be used to create a pseudo node
|
||||
func externalNodeID(n report.Node, addr string, local report.Networks) (string, bool) {
|
||||
// First, check if it's a known service and emit a a specific node if it
|
||||
|
||||
@@ -91,18 +91,12 @@ var ProcessNameRenderer = ConditionalRenderer(renderProcesses,
|
||||
|
||||
// MapEndpoint2Pseudo makes internet of host pesudo nodes from a endpoint node.
|
||||
func MapEndpoint2Pseudo(n report.Node, local report.Networks) report.Nodes {
|
||||
_, addr, _, ok := report.ParseEndpointNodeID(n.ID)
|
||||
id, ok := pseudoNodeID(n, local)
|
||||
if !ok {
|
||||
return report.Nodes{}
|
||||
}
|
||||
|
||||
if externalNode, ok := NewDerivedExternalNode(n, addr, local); ok {
|
||||
return report.Nodes{externalNode.ID: externalNode}
|
||||
}
|
||||
|
||||
// due to https://github.com/weaveworks/scope/issues/1323 we are dropping
|
||||
// all non-external pseudo nodes for now.
|
||||
return report.Nodes{}
|
||||
externalNode := NewDerivedPseudoNode(id, n)
|
||||
return report.Nodes{externalNode.ID: externalNode}
|
||||
}
|
||||
|
||||
// MapEndpoint2Process maps endpoint Nodes to process
|
||||
|
||||
Reference in New Issue
Block a user