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)
| 361 | // If no merge options is supplied, then destination field is replaced |
| 362 | // with the given value. |
| 363 | func 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 |
no outgoing calls
no test coverage detected