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.
Click to show internal directories.
Click to hide internal directories.