MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / patchFieldValueToObject

Function patchFieldValueToObject

patches.go:363–374  ·  view source on GitHub ↗

patchFieldValueToObject applies the value to the "to" object at the given path, returning any errors as they occur. If no merge options is supplied, then destination field is replaced with the given value.

(fieldPath string, value any, to runtime.Object, mo *xpv1.MergeOptions)

Source from the content-addressed store, hash-verified

361// If no merge options is supplied, then destination field is replaced
362// with the given value.
363func patchFieldValueToObject(fieldPath string, value any, to runtime.Object, mo *xpv1.MergeOptions) error {
364 paved, err := fieldpath.PaveObject(to)
365 if err != nil {
366 return err
367 }
368
369 if err := paved.MergeValue(fieldPath, value, mo); err != nil {
370 return err
371 }
372
373 return runtime.DefaultUnstructuredConverter.FromUnstructured(paved.UnstructuredContent(), to)
374}
375
376// patchFieldValueToMultiple, given a path with wildcards in an array index,
377// expands the arrays paths in the "to" object and patches the value into each

Callers 2

ApplyFromFieldPathPatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected