static

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Overview

Package static provides an unstructured resource primitive for static Kubernetes objects that do not model convergence health, grace periods, or suspension.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is a configuration helper for creating and customizing a static unstructured Resource.

It provides a fluent API for registering mutations and data extractors. Build() validates the configuration and returns an initialized Resource ready for use in a reconciliation loop.

func NewBuilder

func NewBuilder(obj *uns.Unstructured) *Builder

NewBuilder initializes a new Builder with the provided unstructured object.

The object serves as the desired base state. During reconciliation the Resource will make the cluster's state match this base, modified by any registered mutations.

The provided object must have a Name set. Namespaced resources must also have a Namespace; cluster-scoped resources must call MarkClusterScoped.

func (*Builder) Build

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

Build validates the configuration and returns the initialized Resource.

It returns an error if:

  • No object was provided.
  • The object is missing a Name.
  • A namespaced object is missing a Namespace (and MarkClusterScoped was not called).
  • A cluster-scoped object has a Namespace set.

func (*Builder) MarkClusterScoped

func (b *Builder) MarkClusterScoped() *Builder

MarkClusterScoped marks the resource as cluster-scoped. Build() will reject a non-empty namespace instead of requiring one.

func (*Builder) WithDataExtractor

func (b *Builder) WithDataExtractor(extractor func(uns.Unstructured) error) *Builder

WithDataExtractor registers a function to read values from the object after it has been successfully reconciled.

The extractor receives a value copy of the reconciled object. A nil extractor is ignored.

func (*Builder) WithGuard added in v0.4.0

func (b *Builder) WithGuard(guard func(uns.Unstructured) (concepts.GuardStatusWithReason, error)) *Builder

WithGuard registers a guard precondition that is evaluated before the object is applied during reconciliation. If the guard returns Blocked, the object and all resources registered after it are skipped until the guard clears. Passing nil clears any previously registered guard.

func (*Builder) WithMutation

func (b *Builder) WithMutation(m unstruct.Mutation) *Builder

WithMutation registers a mutation for the unstructured object.

Mutations are applied sequentially during the Mutate() phase of reconciliation. A mutation with a nil Feature is applied unconditionally; one with a non-nil Feature is applied only when that feature is enabled.

type Resource

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

Resource is a high-level abstraction for managing a static unstructured Kubernetes object within a controller's reconciliation loop.

It implements the following interfaces:

  • component.Resource: for basic identity and mutation behaviour.
  • concepts.Guardable: for conditional reconciliation based on a guard precondition.
  • concepts.DataExtractable: for exporting values after successful reconciliation.

Static unstructured resources do not model convergence health, grace periods, or suspension. Use the workload, integration, or task unstructured variants for resources that require those concepts.

func (*Resource) ExtractData

func (r *Resource) ExtractData() error

ExtractData executes all registered data extractor functions against a deep copy of the reconciled object.

func (*Resource) GuardStatus added in v0.4.0

func (r *Resource) GuardStatus() (concepts.GuardStatusWithReason, error)

GuardStatus evaluates the resource's guard precondition. If no guard was registered, the resource is unconditionally unblocked.

func (*Resource) Identity

func (r *Resource) Identity() string

Identity returns a unique identifier for the resource derived from its GVK, namespace, and name.

func (*Resource) Mutate

func (r *Resource) Mutate(current client.Object) error

Mutate transforms the current state of the unstructured object into the desired state by applying all registered feature mutations.

func (*Resource) Object

func (r *Resource) Object() (client.Object, error)

Object returns a deep copy of the underlying unstructured Kubernetes object.

func (*Resource) PreviewObject added in v0.6.0

func (r *Resource) PreviewObject() (*uns.Unstructured, error)

PreviewObject returns the object as it would appear after feature mutations have been applied, without modifying the resource's internal state.

Suspension mutations are not applied; the preview reflects content state only.

Jump to

Keyboard shortcuts

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