loader

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 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 (
	// ErrStop is used during Walk to stop recursing.
	ErrStop = errors.New("stop")
)

Functions

func LoadBytes

func LoadBytes(data []byte) ([]*resource.Resource, error)

func LoadPath

func LoadPath(
	fs filesys.FileSystem,
	path string,
) (
	[]*resource.Resource,
	error,
)

LoadPath loads all resources under path from fs recursively.

Types

type ClientSet

type ClientSet struct {
	client.Client
	// contains filtered or unexported fields
}

ClientSet implements client.Client interface, handled Get and GroupVersionKindFor.

func NewClientSet

func NewClientSet(scheme *runtime.Scheme, root *ResourceNode) *ClientSet

NewClientSet form scheme and resource tree.

func (ClientSet) Get

Get a particular resource from the tree.

func (ClientSet) GroupVersionKindFor

func (c ClientSet) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)

GroupVersionKindFor an object.

type Context

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

func (*Context) ClientSet

func (m *Context) ClientSet() client.Client

func (*Context) GetAttachment

func (m *Context) GetAttachment(kind, namespace, name string) (any, bool)

func (*Context) GetResource

func (m *Context) GetResource(kind, namespace, name string) (*controller.Resource, bool)

type Manager

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

Manager runs controllers, builds and queries the resource tree.

func NewManager

func NewManager(
	logger zerolog.Logger,
	controllers []controller.Controller,
) *Manager

NewManager from a slice of controllers.

func (*Manager) AddResources

func (m *Manager) AddResources(resources []*controller.Resource)

AddResources seeds the resource tree with additional resources before Run.

func (*Manager) AllNodes

func (m *Manager) AllNodes() []*ResourceNode

AllNodes returns a flat representation of all resource nodes encountered during Run.

func (*Manager) Initialize

func (m *Manager) Initialize(
	fs filesys.FileSystem,
	path string,
	defaultNamespace string,
) error

Initialize the resource tree by loading some resources.

func (*Manager) ListWithKind

func (m *Manager) ListWithKind(kind, namespace string, allNamespaces bool) []*ResourceNode

ListWithKind retrieves resources that are of a specific kind.

func (*Manager) Run

func (m *Manager) Run() error

Run the manager until completion. Reconciliation is finished if no more resources are created or all controllers report errors that could not be resolved.

type ResourceNode

type ResourceNode struct {
	// Status of this particular node/resource.
	Status ResourceStatus
	// Attempts taken to reconcile.
	Attempts int
	// Error that occurred during reconciliation.
	Error error
	// Time it took to reconcile this resource.
	Duration time.Duration
	// Resource this node contains, or nil for the root.
	Resource *controller.Resource
	// Attachment set on this node.
	Attachment any
	// Children of this resource.
	Children []*ResourceNode
}

func (*ResourceNode) AddResources

func (n *ResourceNode) AddResources(res []*controller.Resource)

AddResources to a node. Created resources will have StatusUnknown.

func (*ResourceNode) Find

func (n *ResourceNode) Find(kind, namespace, name string) (*ResourceNode, bool)

Find a specific node in the ResourceNode.

func (*ResourceNode) Flat

func (n *ResourceNode) Flat() ResourceNodes

Flat returns a flat list of all resource nodes, that have a resource attached.

func (*ResourceNode) FlatByStatus

func (n *ResourceNode) FlatByStatus(status ResourceStatus) ResourceNodes

FlatByStatus returns a flat list of all resource nodes, that have a specific status.

func (*ResourceNode) GetResources

func (n *ResourceNode) GetResources() []*ResourceNode

GetResources retrieves all resources that are children of this node, recursively. Recursion is stopped when a `Kustomization` is encountered.

func (*ResourceNode) String

func (n *ResourceNode) String() string

String representation of a resource node.

func (*ResourceNode) Walk

func (n *ResourceNode) Walk(f func(node *ResourceNode) error) error

Walk the resource node recursively.

type ResourceNodes

type ResourceNodes []*ResourceNode

ResourceNodes is a slice of ResourceNodes.

func (ResourceNodes) FilterByKind

func (n ResourceNodes) FilterByKind(kind string) ResourceNodes

FilterByKind returns only nodes that are of a particular kind.

func (ResourceNodes) FilterByNamespace

func (n ResourceNodes) FilterByNamespace(ns string) ResourceNodes

FilterByNamespace returns only nodes in a particular namespace.

type ResourceStatus

type ResourceStatus int
const (
	StatusUnknown ResourceStatus = iota
	StatusCompleted
	StatusError
)

Jump to

Keyboard shortcuts

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