graph

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RelOwns     = resource.RelOwns
	RelRunsOn   = resource.RelRunsOn
	RelUses     = resource.RelUses
	RelExposes  = resource.RelExposes
	RelManages  = resource.RelManages
	RelMemberOf = resource.RelMemberOf
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DependencyNode

type DependencyNode struct {
	Edge     GraphEdge        `json:"edge"`
	Children []DependencyNode `json:"children"`
}

type DependencyTree

type DependencyTree struct {
	Root     GraphNode        `json:"root"`
	Children []DependencyNode `json:"children"`
}

type Direction

type Direction int

Direction controls which edges GetRelated returns.

const (
	Outgoing Direction = iota
	Incoming
	Both
)

type GraphEdge

type GraphEdge struct {
	Source GraphNode        `json:"source"`
	Target GraphNode        `json:"target"`
	Type   RelationshipType `json:"type"`
	Label  string           `json:"label"`
}

type GraphNode

type GraphNode struct {
	PluginID     string `json:"pluginId"`
	ConnectionID string `json:"connectionId"`
	ResourceKey  string `json:"resourceKey"`
	ID           string `json:"id"`
	Namespace    string `json:"namespace,omitempty"`
}

GraphNode identifies a specific resource instance in the graph.

func (GraphNode) Key

func (n GraphNode) Key() string

Key returns a unique string for this node. Uses "/" as separator — callers must ensure component values do not contain "/".

type Indexer added in v0.4.0

type Indexer struct {
	// contains filtered or unexported fields
}

func NewGraphIndexer

func NewGraphIndexer(graph *RelationshipGraph, store registry.Store) *Indexer

func (*Indexer) CheckLabelSelectorsForEntry added in v0.4.0

func (gi *Indexer) CheckLabelSelectorsForEntry(entry registry.ResourceEntry)

CheckLabelSelectorsForEntry checks if any cached selectors match the labels on a newly added/updated entry.

func (*Indexer) Name added in v0.4.0

func (gi *Indexer) Name() string

func (*Indexer) OnAdd added in v0.4.0

func (gi *Indexer) OnAdd(entry registry.ResourceEntry, raw json.RawMessage)

func (*Indexer) OnDelete added in v0.4.0

func (gi *Indexer) OnDelete(entry registry.ResourceEntry)

OnDelete withdraws the edges derived from this resource's data. Field-path edges other resources declared to it stay, like references to resources that do not exist yet, and resolve again if it is recreated.

func (*Indexer) OnUpdate added in v0.4.0

func (gi *Indexer) OnUpdate(old, updated registry.ResourceEntry, raw json.RawMessage)

OnUpdate re-derives the edges that come from this resource's data. Edges other resources declared about it (a Pod's "runs on" edge to an updated Node, a Pod's ownership edge from an updated ReplicaSet) are left alone.

type RelationshipGraph

type RelationshipGraph struct {
	// contains filtered or unexported fields
}

func NewRelationshipGraph

func NewRelationshipGraph() *RelationshipGraph

func (*RelationshipGraph) AddDeclaredEdge added in v0.4.1

func (g *RelationshipGraph) AddDeclaredEdge(edge GraphEdge, declarerKey string, viaSelector bool)

AddDeclaredEdge adds an edge derived from the data of the node with key declarerKey. viaSelector marks edges found by matching the declarer's label selector. Such edges are withdrawn by RemoveDerivedEdges.

func (*RelationshipGraph) AddEdge

func (g *RelationshipGraph) AddEdge(edge GraphEdge)

AddEdge adds an edge that is not tied to any declaring node. It is removed only by RemoveEdgesForNode or RemoveEdgesForConnection.

func (*RelationshipGraph) ClearDeclarationsForPlugin

func (g *RelationshipGraph) ClearDeclarationsForPlugin(pluginID string)

func (*RelationshipGraph) EdgesFrom

func (g *RelationshipGraph) EdgesFrom(nodeKey string) []GraphEdge

func (*RelationshipGraph) EdgesTo

func (g *RelationshipGraph) EdgesTo(nodeKey string) []GraphEdge

func (*RelationshipGraph) GetDeclarations

func (g *RelationshipGraph) GetDeclarations(resourceKey string) []resource.RelationshipDescriptor

GetDeclarations returns declarations for a resource key across all plugins.

func (*RelationshipGraph) GetDependencyTree

func (g *RelationshipGraph) GetDependencyTree(ref GraphNode, maxDepth int) (*DependencyTree, error)

GetDependencyTree follows ALL outgoing edge types recursively from root. maxDepth is capped at 5 to prevent explosion.

func (*RelationshipGraph) GetRelated

func (g *RelationshipGraph) GetRelated(
	ref GraphNode,
	direction Direction,
	relType *RelationshipType,
) ([]GraphEdge, error)

GetRelated returns edges connected to the given node, filtered by direction and type.

func (*RelationshipGraph) GetRelationshipChain

func (g *RelationshipGraph) GetRelationshipChain(
	ref GraphNode,
	relType RelationshipType,
	maxDepth int,
) ([][]GraphEdge, error)

GetRelationshipChain follows edges of a specific type up to maxDepth hops. Returns edges organized by depth level. Uses BFS with visited-set cycle detection.

func (*RelationshipGraph) GetSelectorCache

func (g *RelationshipGraph) GetSelectorCache(nodeKey string) (map[string]string, bool)

func (*RelationshipGraph) RemoveDerivedEdges added in v0.4.1

func (g *RelationshipGraph) RemoveDerivedEdges(nodeKey string)

RemoveDerivedEdges withdraws the edges derived from the given node's data: edges it declared (in either direction) and selector edges that matched its labels. Edges other nodes declared about it stay, so a change to a Node does not drop the Pods' "runs on" edges to it. Also drops the node's cached selector.

func (*RelationshipGraph) RemoveEdgesForConnection

func (g *RelationshipGraph) RemoveEdgesForConnection(pluginID, connectionID string)

func (*RelationshipGraph) RemoveEdgesForNode

func (g *RelationshipGraph) RemoveEdgesForNode(nodeKey string)

func (*RelationshipGraph) SetDeclarations

func (g *RelationshipGraph) SetDeclarations(pluginID, resourceKey string, decls []resource.RelationshipDescriptor)

func (*RelationshipGraph) SetSelectorCache

func (g *RelationshipGraph) SetSelectorCache(node GraphNode, selector map[string]string)

type RelationshipType

type RelationshipType = resource.RelationshipType

RelationshipType re-exports from SDK for convenience.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL