patch

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPatches

func ApplyPatches(resource map[string]any, operations []JSONPatchOperation) error

ApplyPatches applies a list of JSON Patch operations to a single resource.

This is the core, low-level patch function with a single responsibility: apply operations to ONE resource. It does NOT handle:

  • Resource targeting (finding which resources to patch)
  • forEach iteration (applying to multiple items)
  • CEL rendering (operations should be pre-rendered)
  • Where clause filtering

Those concerns are handled by higher-level orchestration code (e.g., trait processor).

Supported operations:

  • add, replace, remove: standard RFC 6902 JSON Patch operations
  • mergeShallow: custom operation that overlays map keys without deep merging

Path expressions support:

  • Array filters: /containers[?(@.name=='app')]/env
  • Array indices: /containers/0/env
  • Append marker: /env/-

The resource is modified in-place.

Types

type JSONPatchOperation

type JSONPatchOperation struct {
	Op    string `yaml:"op"`
	Path  string `yaml:"path"`
	Value any    `yaml:"value,omitempty"`
}

JSONPatchOperation represents a single patch operation in a JSON Patch specification.

Jump to

Keyboard shortcuts

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