unstructured

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: 5 Imported by: 0

Documentation

Overview

Package unstructured provides shared types for building unstructured Kubernetes resource primitives.

It defines the Mutator and Mutation types used by all four concept-specific sub-packages (workload, integration, static, task). The Mutator follows the same plan-and-apply pattern used by typed primitives: mutations are recorded first, then applied in a single controlled pass when Apply() is called.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeIdentityFunc

func MakeIdentityFunc(clusterScoped bool) func(*uns.Unstructured) string

MakeIdentityFunc constructs an identity function for unstructured objects.

The returned function produces a stable framework identity derived from the object's GVK, namespace, and name:

  • Cluster-scoped: "{group}/{version}/{kind}/{name}"
  • Namespaced: "{group}/{version}/{kind}/{namespace}/{name}"

Types

type Mutation

type Mutation feature.Mutation[*Mutator]

Mutation defines a mutation that is applied to an unstructured Mutator only if its associated feature gate is enabled.

type Mutator

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

Mutator is a high-level helper for modifying a Kubernetes unstructured object.

It uses a "plan-and-apply" pattern: mutations are recorded first, then applied to the object in a single controlled pass when Apply() is called.

The Mutator maintains feature boundaries: each feature's mutations are planned together and applied in the order the features were registered.

Mutator implements editors.ObjectMutator.

func NewMutator

func NewMutator(obj *uns.Unstructured) *Mutator

NewMutator creates a new Mutator for the given unstructured object. The constructor creates the initial feature scope, so mutations can be registered immediately without an explicit call to NextFeature.

func (*Mutator) Apply

func (m *Mutator) Apply() error

Apply executes all recorded mutation intents on the underlying unstructured object.

Execution order across all registered features:

  1. Metadata edits (in registration order within each feature)
  2. Content edits (in registration order within each feature)

Features are applied in the order they were registered. Later features observe the object as modified by all previous features.

Since *unstructured.Unstructured does not embed metav1.ObjectMeta, metadata edits are bridged: a temporary ObjectMeta is populated from the object's labels and annotations, the ObjectMetaEditor mutates it, and the results are written back via SetLabels/SetAnnotations.

func (*Mutator) EditContent

func (m *Mutator) EditContent(edit func(*editors.UnstructuredContentEditor) error)

EditContent records a mutation for the unstructured object's content via an UnstructuredContentEditor.

The editor provides structured operations (SetNestedField, RemoveNestedField, typed setters) as well as Raw() for free-form access. Content edits are applied after metadata edits within the same feature, in registration order.

A nil edit function is ignored.

func (*Mutator) EditObjectMetadata

func (m *Mutator) EditObjectMetadata(edit func(*editors.ObjectMetaEditor) error)

EditObjectMetadata records a mutation for the unstructured object's metadata.

Metadata edits are applied before content edits within the same feature. A nil edit function is ignored.

func (*Mutator) NextFeature

func (m *Mutator) NextFeature()

NextFeature advances to a new feature planning scope. All subsequent mutation registrations will be grouped into this scope until NextFeature is called again.

The first scope is created automatically by NewMutator. This method is called by the framework between mutations to maintain per-feature ordering semantics.

Directories

Path Synopsis
Package integration provides an unstructured resource primitive for Kubernetes integration objects that depend on external assignments and require operational status tracking and suspension support.
Package integration provides an unstructured resource primitive for Kubernetes integration objects that depend on external assignments and require operational status tracking and suspension support.
Package static provides an unstructured resource primitive for static Kubernetes objects that do not model convergence health, grace periods, or suspension.
Package static provides an unstructured resource primitive for static Kubernetes objects that do not model convergence health, grace periods, or suspension.
Package task provides an unstructured resource primitive for Kubernetes objects that run to completion, requiring completion status tracking and suspension support.
Package task provides an unstructured resource primitive for Kubernetes objects that run to completion, requiring completion status tracking and suspension support.
Package workload provides an unstructured resource primitive for long-running Kubernetes workload objects that require health tracking, graceful rollouts, and suspension support.
Package workload provides an unstructured resource primitive for long-running Kubernetes workload objects that require health tracking, graceful rollouts, and suspension support.

Jump to

Keyboard shortcuts

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