controller

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Scheme = runtime.NewScheme()

Scheme to use for building k8s ClientSets.

Functions

func Any

func Any[T comparable](items ...T) T

Any returns the first non-zero value, or zero.

Types

type Context

type Context interface {
	// ClientSet for a subset of resource kinds. Must implement Get and List methods.
	ClientSet() client.Client
	// GetAttachment for a specific resource that any controller added during the Reconcile
	// invocation.
	GetAttachment(kind, namespace, name string) (any, bool)
	// GetResource with specific kind, namespace and name. Use this over ClientSet().Get(...) if the
	// ApiVersion of a resource is unknown or ambiguous. Returns the first resource matched in a resource tree.
	GetResource(kind, namespace, name string) (*Resource, bool)
}

type Controller

type Controller interface {
	// Kinds this controller will accept. Only resources of this API kind will be handled, e.g. "Secret",
	// "Kustomization". Scope a controller as narrow as possible.
	Kinds() []string
	// Reconcile is invoked for each resource. Returns a list of resources to create
	// and an error. If error is ErrSkip, the controller is skipped for this invocation.
	Reconcile(Context, *Resource) (*Result, error)
}

Controller defines a reconciliation loop.

type Resource

type Resource struct {
	*resource.Resource
}

Resource that contains a single arbitrary k8s manifest.

func NewResource

func NewResource(r *resource.Resource) *Resource

NewResource from a kustomize resource.

func NewResources

func NewResources(r []*resource.Resource) []*Resource

NewResources from kustomize resources.

func (Resource) Unmarshal

func (r Resource) Unmarshal(dest any) error

Unmarshal resource into dest.

func (Resource) Unstructured

func (r Resource) Unstructured() (*unstructured.Unstructured, error)

Unstructured representation of this resource.

type Result

type Result struct {
	// Resources that are created based on the handled resource, e.g. ExternalSecret creates a Secret.
	Resources []*Resource
	// Attachment that should be stored alongside this resource node, or nil. Attachments can be retrieved
	// using Context.GetAttachment.
	Attachment any
}

Result of a single reconciliation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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