mutation

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyResourceMutation

func ApplyResourceMutation(value any, mut syncagentv1alpha1.ResourceMutation, ctx *TemplateMutationContext) (any, error)

func ApplyResourceMutations

func ApplyResourceMutations(value any, mutations []syncagentv1alpha1.ResourceMutation, ctx *TemplateMutationContext) (any, error)

Types

type Mutator

type Mutator interface {
	// MutateSpec transform a remote object into a local one. On the first
	// mutation, otherObj will be nil. MutateSpec can modify all fields
	// except the status (i.e. "mutate spec" here means to mutate expected state,
	// which can be more than just the spec).
	MutateSpec(toMutate *unstructured.Unstructured, otherObj *unstructured.Unstructured) (*unstructured.Unstructured, error)
	// MutateStatus transform a local object into a remote one. MutateStatus
	// must only modify the status field.
	MutateStatus(toMutate *unstructured.Unstructured, otherObj *unstructured.Unstructured) (*unstructured.Unstructured, error)
}

func NewMutator

NewMutator creates a new mutator, which will apply the mutation rules to a synced object, in both directions. A nil spec is supported and will simply make the mutator not do anything.

type TemplateMutationContext

type TemplateMutationContext struct {
	// Value is always set by this package to the value found in the document.
	Value gjson.Result

	LocalObject  map[string]any
	RemoteObject map[string]any
}

Jump to

Keyboard shortcuts

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