mutation

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op struct {
	Path      *PathExpr
	Condition cel.Program
	Value     any
}

Op is an operation that conditionally assigns a value to a path within an object. Designed to be sent over the wire as JSON.

func (*Op) Apply

func (o *Op) Apply(ctx context.Context, comp *apiv1.Composition, current, mutated *unstructured.Unstructured) (Status, error)

Apply applies the operation to the "mutated" object if the condition is met by the "current" object.

func (*Op) UnmarshalJSON

func (o *Op) UnmarshalJSON(data []byte) error

type PathExpr

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

PathExpr represents an expression that can be used to access or modify values in a nested structure.

func ParsePathExpr

func ParsePathExpr(expr string) (*PathExpr, error)

ParsePathExpr parses a path expression string.

Supported syntax: - `field.anotherfield`: object field traversal - `field["anotherField"]` or `field['anotherField']`: alternative object field traversal (supports any field name including hyphens) - `field[2]`: array indexing - `field[*]`: array wildcards - `field[someKey="value"]`: object array field matchers

Expressions can be chained, e.g. `field.anotherfield[2].yetAnotherField`. For field names containing special characters like hyphens, use bracket notation: `field['foo-bar']`.

func (*PathExpr) Apply added in v0.1.33

func (p *PathExpr) Apply(obj, value any) (Status, error)

Apply applies a mutation i.e. sets the value(s) referred to by the path expression. Missing or nil values in the path will not be created, and will cause an error.

func (*PathExpr) ManagedByEno added in v0.1.25

func (p *PathExpr) ManagedByEno(ctx context.Context, current *unstructured.Unstructured) bool

func (*PathExpr) String added in v0.1.33

func (p *PathExpr) String() string

type Status added in v0.1.33

type Status string
const (
	StatusActive           Status = "Active"
	StatusInactive         Status = "Inactive"
	StatusInvalidCondition Status = "InvalidCondition"
	StatusMissingParent    Status = "MissingParent"
	StatusIndexOutOfRange  Status = "IndexOutOfRange"
	StatusPathTypeMismatch Status = "PathTypeMismatch"
)

Jump to

Keyboard shortcuts

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