patchFieldValueToMultiple, given a path with wildcards in an array index, expands the arrays paths in the "to" object and patches the value into each of the resulting fields, returning any errors as they occur.
(fieldPath string, value any, to runtime.Object, mo *xpv1.MergeOptions)
| 377 | // expands the arrays paths in the "to" object and patches the value into each |
| 378 | // of the resulting fields, returning any errors as they occur. |
| 379 | func patchFieldValueToMultiple(fieldPath string, value any, to runtime.Object, mo *xpv1.MergeOptions) error { |
| 380 | paved, err := fieldpath.PaveObject(to) |
| 381 | if err != nil { |
| 382 | return err |
| 383 | } |
| 384 | |
| 385 | arrayFieldPaths, err := paved.ExpandWildcards(fieldPath) |
| 386 | if err != nil { |
| 387 | return err |
| 388 | } |
| 389 | |
| 390 | if len(arrayFieldPaths) == 0 { |
| 391 | return errors.Errorf(errFmtExpandingArrayFieldPaths, fieldPath) |
| 392 | } |
| 393 | |
| 394 | for _, field := range arrayFieldPaths { |
| 395 | if err := paved.MergeValue(field, value, mo); err != nil { |
| 396 | return err |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | return runtime.DefaultUnstructuredConverter.FromUnstructured(paved.UnstructuredContent(), to) |
| 401 | } |
no outgoing calls
no test coverage detected