topology

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGraphMaxDepth = 3
)

Variables

This section is empty.

Functions

func MustAccessObject

func MustAccessObject[T any](node *Node, concreteObj T) T

Types

type Builder

type Builder struct {
	Sources   []*unstructured.Unstructured
	Relations []*Relation
	Fetcher   common.GroupKindFetcher
	MaxDepth  int
}

func NewBuilder

func NewBuilder(fetcher common.GroupKindFetcher) *Builder

func (*Builder) Build

func (b *Builder) Build() (*Graph, error)

func (*Builder) StartFrom

func (b *Builder) StartFrom(sources []*unstructured.Unstructured) *Builder

func (*Builder) UseRelationship

func (b *Builder) UseRelationship(relation *Relation) *Builder

func (*Builder) UseRelationships

func (b *Builder) UseRelationships(relations []*Relation) *Builder

func (*Builder) WithMaxDepth

func (b *Builder) WithMaxDepth(maxDepth int) *Builder

type Graph

type Graph struct {
	Nodes   map[schema.GroupKind]map[types.NamespacedName]*Node
	Sources []*Node
	// MaxDepth represents the value of the maximum depth parameter used while
	// performing the BFS from Source nodes. Note that terminal nodes can have a
	// depth equal to MaxDepth+1. Any validations that need to happen should be
	// done for nodes <= MaxDepth. This ensures that any external references
	// from nodes <= MaxDepth can be validated.
	MaxDepth  int
	Relations []*Relation
}

func (*Graph) AddEdge

func (g *Graph) AddEdge(from *Node, to *Node, relation *Relation)

func (*Graph) AddNode

func (g *Graph) AddNode(node *Node)

func (*Graph) DeleteNode

func (g *Graph) DeleteNode(node *Node)

func (*Graph) DeleteNodeUsingGKNN

func (g *Graph) DeleteNodeUsingGKNN(nodeGKNN common.GKNN)

func (*Graph) HasNode

func (g *Graph) HasNode(nodeGKNN common.GKNN) bool

func (*Graph) RemoveEdge

func (g *Graph) RemoveEdge(from *Node, to *Node, relation *Relation)

func (*Graph) RemoveMetadata

func (g *Graph) RemoveMetadata(category string)

type NeighborFunc

type NeighborFunc func(*unstructured.Unstructured) []common.GKNN

type Node

type Node struct {
	Object       *unstructured.Unstructured
	InNeighbors  map[*Relation]map[common.GKNN]*Node
	OutNeighbors map[*Relation]map[common.GKNN]*Node
	Depth        int
	Metadata     map[string]any
}

func SortedNodes

func SortedNodes(nodes []*Node) []*Node

func (*Node) GKNN

func (n *Node) GKNN() common.GKNN

type Relation

type Relation struct {
	From         schema.GroupKind
	To           schema.GroupKind
	Name         string
	NeighborFunc NeighborFunc
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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