Documentation ¶
Index ¶
- Constants
- func AddReversedEdge(g Interface, head, tail graph.Node, edgeKinds sets.String) bool
- func AllNodes(g Interface, node graph.Node) bool
- func EnsureUnique(g UniqueNodeInitializer, name UniqueName, fn NodeInitializerFunc) graph.Node
- func ExistingDirectEdge(g Interface, head, tail graph.Node, edgeKinds sets.String) bool
- func GetContainingNode(g Graph, containedNode graph.Node) graph.Node
- func GetTopLevelContainerNode(g Graph, containedNode graph.Node) graph.Node
- func NodesByKind(g Interface, nodes []graph.Node, kinds ...string) [][]graph.Node
- func ReverseExistingDirectEdge(g Interface, head, tail graph.Node, edgeKinds sets.String) bool
- func ReverseGraphEdge(g Interface, head, tail graph.Node, edgeKinds sets.String) bool
- type ByID
- type ByKey
- type ByNodeID
- type BySeverity
- type Edge
- type EdgeFunc
- type ExistenceChecker
- type Graph
- func (g Graph) AddEdge(head, tail graph.Node, edgeKind string)
- func (g Graph) AddNode(n graph.Node)
- func (g Graph) ConnectedEdgeSubgraph(fn EdgeFunc) Graph
- func (g Graph) EdgeSubgraph(edgeFn EdgeFunc) Graph
- func (g Graph) Edges() []graph.Edge
- func (g Graph) Find(name UniqueName) graph.Node
- func (g Graph) FindOrCreate(name UniqueName, fn NodeInitializerFunc) (graph.Node, bool)
- func (g Graph) InboundEdges(node graph.Node, edgeKinds ...string) []graph.Edge
- func (g Graph) NodesByKind(nodeKinds ...string) []graph.Node
- func (g Graph) OutboundEdges(node graph.Node, edgeKinds ...string) []graph.Edge
- func (g Graph) PredecessorEdges(node graph.Node, fn EdgeFunc, edgeKinds ...string)
- func (g Graph) PredecessorNodesByEdgeKind(node graph.Node, edgeKinds ...string) []graph.Node
- func (g Graph) RootNodes() []graph.Node
- func (g Graph) String() string
- func (g Graph) Subgraph(nodeFn NodeFunc, edgeFn EdgeFunc) Graph
- func (g Graph) SubgraphWithNodes(nodes []graph.Node, fn EdgeFunc) Graph
- func (g Graph) SuccessorEdges(node graph.Node, fn EdgeFunc, edgeKinds ...string)
- func (g Graph) SuccessorNodesByEdgeKind(node graph.Node, edgeKinds ...string) []graph.Node
- func (g Graph) SuccessorNodesByNodeAndEdgeKind(node graph.Node, nodeKind, edgeKind string) []graph.Node
- func (g Graph) SyntheticNodes() []graph.Node
- type GraphDescriber
- type Interface
- type Marker
- type MarkerScanner
- type Markers
- type MutableDirectedEdge
- type MutableUniqueGraph
- type Node
- type NodeFinder
- type NodeFunc
- type NodeInitializerFunc
- type NodeSet
- type ResourceNode
- type Severity
- type Suggestion
- type UniqueName
- type UniqueNameFunc
- type UniqueNodeInitializer
Constants ¶
const ( UnknownEdgeKind = "UnknownEdge" // ReferencedByEdgeKind is the kind to use if you're building reverse links that don't have a specific edge in the other direction // other uses are discouraged. You should create a kind for your edge ReferencedByEdgeKind = "ReferencedBy" // ContainsEdgeKind is the kind to use if one node's contents logically contain another node's contents. A given node can only have // a single inbound Contais edge. The code does not prevent contains cycles, but that's insane, don't do that. ContainsEdgeKind = "Contains" )
const (
UnknownNodeKind = "UnknownNode"
)
Variables ¶
This section is empty.
Functions ¶
func AddReversedEdge ¶
AddReversedEdge adds a reversed edge for every passed edge and preserves the existing edge. Used to convert a one directional edge into a bidirectional edge, but will create duplicate edges if a bidirectional edge between two nodes already exists.
func EnsureUnique ¶
func EnsureUnique(g UniqueNodeInitializer, name UniqueName, fn NodeInitializerFunc) graph.Node
func ExistingDirectEdge ¶
ExistingDirectEdge returns true if both head and tail already exist in the graph and the edge kind is not ReferencedByEdgeKind (the generic reverse edge kind). This will purge the graph of any edges created by AddReversedEdge.
func GetContainingNode ¶ added in v1.0.1
GetContainingNode returns the direct predecessor that is linked to the node by a ContainsEdgeKind. It returns nil if no container is found.
func GetTopLevelContainerNode ¶ added in v1.0.1
GetTopLevelContainerNode traverses the reverse ContainsEdgeKind edges until it finds a node that does not have an inbound ContainsEdgeKind edge. This could be the node itself
func NodesByKind ¶
func ReverseExistingDirectEdge ¶
ReverseExistingDirectEdge reverses the order of the edge and drops the existing edge only if both head and tail already exist in the graph and the edge kind is not ReferencedByEdgeKind (the generic reverse edge kind).
Types ¶
type BySeverity ¶ added in v1.0.4
type BySeverity []Marker
func (BySeverity) Len ¶ added in v1.0.4
func (m BySeverity) Len() int
func (BySeverity) Less ¶ added in v1.0.4
func (m BySeverity) Less(i, j int) bool
func (BySeverity) Swap ¶ added in v1.0.4
func (m BySeverity) Swap(i, j int)
type Edge ¶
func (Edge) DOTAttributes ¶ added in v1.0.4
DOTAttributes implements an attribute getter for the DOT encoding
type EdgeFunc ¶
EdgeFunc is passed a new graph, an edge in the current graph, and should mutate the new graph as needed. If true is returned, the existing edge will be added to the graph.
func AddGraphEdgesTo ¶
AddGraphEdgesTo returns an EdgeFunc that will add the selected edges to the passed graph.
func EdgesOfKind ¶ added in v1.0.3
EdgesOfKind returns a new EdgeFunc accepting the provided kinds of edges If no kinds are specified, the returned EdgeFunc will accept all edges
func RemoveInboundEdges ¶ added in v1.0.4
RemoveInboundEdges returns a new EdgeFunc dismissing any inbound edges to the provided set of nodes
type ExistenceChecker ¶ added in v1.0.2
type ExistenceChecker interface { // Found returns false if the node represents an object that we don't have the backing object for Found() bool }
ExistenceChecker is an interface for those nodes that can be created without a backing object. This can happen when a node wants an edge to a non-existent node. We know the node should exist, The graph needs something in that location to track the information we have about the node, but the backing object doesn't exist.
type Graph ¶
type Graph struct { // the standard graph graph.Directed // helper methods for switching on the kind and types of the node GraphDescriber // contains filtered or unexported fields }
func (Graph) ConnectedEdgeSubgraph ¶
ConnectedEdgeSubgraph creates a new graph that iterates through all edges in the graph and includes all edges the provided function returns true for. Nodes not referenced by an edge will be dropped unless the function adds them explicitly.
func (Graph) EdgeSubgraph ¶
EdgeSubgraph returns the directed subgraph with only the edges that match the provided function.
func (Graph) Edges ¶ added in v1.0.3
Edges returns all the edges of the graph. Note that the returned set will have no specific ordering.
func (Graph) Find ¶ added in v0.5.3
func (g Graph) Find(name UniqueName) graph.Node
func (Graph) FindOrCreate ¶
func (g Graph) FindOrCreate(name UniqueName, fn NodeInitializerFunc) (graph.Node, bool)
func (Graph) InboundEdges ¶ added in v1.0.1
InboundEdges returns all the inbound edges to node that are in the list of edgeKinds if edgeKinds is empty, then all edges are returned
func (Graph) NodesByKind ¶ added in v1.0.2
NodesByKind returns all the nodes of the graph with the provided kinds
func (Graph) OutboundEdges ¶ added in v1.0.1
OutboundEdges returns all the outbound edges from node that are in the list of edgeKinds if edgeKinds is empty, then all edges are returned
func (Graph) PredecessorEdges ¶
PredecessorEdges invokes fn with all of the predecessor edges of node that have the specified edge kind.
func (Graph) PredecessorNodesByEdgeKind ¶ added in v1.0.2
PredecessorNodesByEdgeKind returns all the predecessor nodes of the given node that can be reached via edges of the provided kinds
func (Graph) Subgraph ¶
Subgraph returns the directed subgraph with only the nodes and edges that match the provided functions.
func (Graph) SubgraphWithNodes ¶
SubgraphWithNodes returns the directed subgraph with only the listed nodes and edges that match the provided function.
func (Graph) SuccessorEdges ¶
SuccessorEdges invokes fn with all of the successor edges of node that have the specified edge kind.
func (Graph) SuccessorNodesByEdgeKind ¶ added in v1.0.2
SuccessorNodesByEdgeKind returns all the successor nodes of the given node that can be reached via edges of the provided kinds
func (Graph) SuccessorNodesByNodeAndEdgeKind ¶ added in v1.0.2
func (Graph) SyntheticNodes ¶ added in v1.0.2
SyntheticNodes returns back the set of nodes that were created in response to edge requests, but did not exist
type GraphDescriber ¶
type Interface ¶
type Interface interface { graph.Directed GraphDescriber MutableUniqueGraph Edges() []graph.Edge }
type Marker ¶ added in v1.0.4
type Marker struct { // Node is the optional node that this message is attached to Node graph.Node // RelatedNodes is an optional list of other nodes that are involved in this marker. RelatedNodes []graph.Node // Severity indicates how important this problem is. Severity Severity // Key is a short string to identify this message Key string // Message is a human-readable string that describes what is interesting Message string // Suggestion is a human-readable string that holds advice for resolving this // marker. Suggestion Suggestion }
Marker is a struct that describes something interesting on a Node
type MarkerScanner ¶ added in v1.0.4
MarkerScanner is a function for analyzing a graph and finding interesting things in it
type MutableDirectedEdge ¶
type MutableUniqueGraph ¶
type MutableUniqueGraph interface { graph.Mutable MutableDirectedEdge UniqueNodeInitializer NodeFinder }
type Node ¶
type Node struct { concrete.Node UniqueName }
func (Node) DOTAttributes ¶ added in v1.0.4
DOTAttributes implements an attribute getter for the DOT encoding
type NodeFinder ¶ added in v0.5.3
type NodeFinder interface {
Find(name UniqueName) graph.Node
}
type NodeFunc ¶
NodeFunc is passed a new graph, a node in the graph, and should return true if the node should be included.
func NodesOfKind ¶ added in v1.0.3
NodesOfKind returns a new NodeFunc accepting the provided kinds of nodes If no kinds are specified, the returned NodeFunc will accept all nodes
type NodeInitializerFunc ¶
type ResourceNode ¶ added in v1.0.2
type ResourceNode interface {
ResourceString() string
}
type Severity ¶ added in v1.0.4
type Severity string
Severity indicates how important this problem is.
type Suggestion ¶ added in v1.1.1
type Suggestion string
func (Suggestion) String ¶ added in v1.1.1
func (s Suggestion) String() string
type UniqueName ¶
type UniqueName string
func GetUniqueRuntimeObjectNodeName ¶ added in v1.0.1
func GetUniqueRuntimeObjectNodeName(nodeKind string, obj runtime.Object) UniqueName
func (UniqueName) UniqueName ¶
func (n UniqueName) UniqueName() string
type UniqueNameFunc ¶ added in v1.0.1
type UniqueNameFunc func(obj interface{}) UniqueName
type UniqueNodeInitializer ¶
type UniqueNodeInitializer interface {
FindOrCreate(name UniqueName, fn NodeInitializerFunc) (graph.Node, bool)
}
UniqueNodeInitializer is a graph that allows nodes with a unique name to be added without duplication. If the node is newly added, true will be returned.