mutation

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MIT Imports: 8 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

This section is empty.

Functions

func Apply

func Apply(path *PathExpr, obj, value any) 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.

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, current, mutated *unstructured.Unstructured) 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[2]`: array indexing - `field[*]`: array wildcards - `field[someKey="value"]`: object array field matchers

Expressions can be chained, e.g. `field.anotherfield[2].yetAnotherField`.

Jump to

Keyboard shortcuts

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