tree

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 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

This section is empty.

Variables

View Source
var LookupResourceHierarchy = &ResourceHierarchy{
	Owned:      map[string]Set{},
	Referenced: map[string]Set{},
}
View Source
var LookupStores = &Stores{
	stores: make(map[string]store.ObjectStore[*unstructured.Unstructured]),
}

Functions

func GetChildren

func GetChildren(ctx context.Context, s store.ObjectStore[*unstructured.Unstructured], tree *ResourceTree, namespace, name string, maxDepth, curDepth int) error

func GetOwner

func GetOwner(ctx context.Context, store store.ObjectStore[*unstructured.Unstructured], tree *ResourceTree, namespace, name string, maxDepth, curDepth int) error

Types

type GVK

type GVK interface {
	GetAPIVersion() string
	GetKind() string
}

type MatchType

type MatchType string
const (
	MatchTypeOwnerReference MatchType = "ownerReference"
)

type OwnerReference

type OwnerReference struct {
	ApiVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	Uid        string `json:"uid"`
}

func GetControllerOf

func GetControllerOf(obj *unstructured.Unstructured) (ref OwnerReference, ok bool)

func (OwnerReference) GetAPIVersion

func (o OwnerReference) GetAPIVersion() string

func (OwnerReference) GetKind

func (o OwnerReference) GetKind() string

type ResourceHierarchy

type ResourceHierarchy struct {
	Owned      map[string]Set
	Referenced map[string]Set
	// contains filtered or unexported fields
}

func (*ResourceHierarchy) AddChild

func (h *ResourceHierarchy) AddChild(parent GVK, child TreeResourceInfo)

func (*ResourceHierarchy) GetChildren

func (h *ResourceHierarchy) GetChildren(parent GVK) []TreeResourceInfo

type ResourceNode

type ResourceNode struct {
	Value      store.Object    `json:"value,omitempty"`
	Children   []*ResourceNode `json:"owns,omitempty"`
	References []*ResourceNode `json:"references,omitempty"`
}

func (*ResourceNode) AddChild

func (n *ResourceNode) AddChild(child *ResourceNode)

func (*ResourceNode) AddNewChild

func (n *ResourceNode) AddNewChild(obj store.Object) *ResourceNode

func (*ResourceNode) AddNewReference

func (n *ResourceNode) AddNewReference(obj *unstructured.Unstructured) *ResourceNode

func (*ResourceNode) AddReference

func (n *ResourceNode) AddReference(ref *ResourceNode)

type ResourceTree

type ResourceTree struct {
	Root *ResourceNode `json:"root,omitempty"`
	// contains filtered or unexported fields
}

func GetTree

func GetTree(ctx context.Context, startStore store.ObjectStore[*unstructured.Unstructured], namespace, name string, maxDepth int) (*ResourceTree, error)

func NewResourceTree

func NewResourceTree() *ResourceTree

func (*ResourceTree) AddNewNode

func (t *ResourceTree) AddNewNode(obj store.Object) *ResourceNode

func (*ResourceTree) AddNode

func (t *ResourceTree) AddNode(node *ResourceNode)

func (*ResourceTree) GetCurrent

func (t *ResourceTree) GetCurrent() *ResourceNode

func (*ResourceTree) ReplaceRoot

func (t *ResourceTree) ReplaceRoot(obj store.Object) *ResourceNode

func (*ResourceTree) SetCurrent

func (t *ResourceTree) SetCurrent(node *ResourceNode)

func (*ResourceTree) SetRoot

func (t *ResourceTree) SetRoot(obj store.Object)

type ResourceTreeController

type ResourceTreeController struct {
	Store store.ObjectStore[*unstructured.Unstructured]
	// contains filtered or unexported fields
}

func (*ResourceTreeController) GetTree

func (r *ResourceTreeController) GetTree(c *fiber.Ctx) error

func (*ResourceTreeController) Register

func (r *ResourceTreeController) Register(router fiber.Router, opts server.ControllerOpts)

type Set

type Set map[TreeResourceInfo]bool

type Stores

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

func (*Stores) AddStore

func (s *Stores) AddStore(store store.ObjectStore[*unstructured.Unstructured])

func (*Stores) GetStore

func (s *Stores) GetStore(groupVersion, kind string) (store.ObjectStore[*unstructured.Unstructured], bool)

type TreeResourceInfo

type TreeResourceInfo struct {
	APIVersion string
	Kind       string
	MatchType  MatchType
}

func (TreeResourceInfo) GetAPIVersion

func (t TreeResourceInfo) GetAPIVersion() string

func (TreeResourceInfo) GetFiltersFor

func (t TreeResourceInfo) GetFiltersFor(obj *unstructured.Unstructured) []store.Filter

func (TreeResourceInfo) GetKind

func (t TreeResourceInfo) GetKind() string

Jump to

Keyboard shortcuts

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