@@ -77,16 +77,16 @@ func ApplyFromFieldPathPatch(p PatchInterface, from, to runtime.Object) error {
77
77
return err
78
78
}
79
79
80
- // ComposedPatch all expanded fields if the ToFieldPath contains wildcards
81
- if strings .Contains (p .GetToFieldPath (), "[*]" ) {
82
- return patchFieldValueToMultiple (p .GetToFieldPath (), out , to )
83
- }
84
-
85
80
mo , err := toMergeOption (p )
86
81
if err != nil {
87
82
return err
88
83
}
89
84
85
+ // ComposedPatch all expanded fields if the ToFieldPath contains wildcards
86
+ if strings .Contains (p .GetToFieldPath (), "[*]" ) {
87
+ return patchFieldValueToMultiple (p .GetToFieldPath (), out , to , mo )
88
+ }
89
+
90
90
return errors .Wrap (patchFieldValueToObject (p .GetToFieldPath (), out , to , mo ), "cannot patch to object" )
91
91
}
92
92
@@ -350,7 +350,7 @@ func patchFieldValueToObject(fieldPath string, value any, to runtime.Object, mo
350
350
// patchFieldValueToMultiple, given a path with wildcards in an array index,
351
351
// expands the arrays paths in the "to" object and patches the value into each
352
352
// of the resulting fields, returning any errors as they occur.
353
- func patchFieldValueToMultiple (fieldPath string , value any , to runtime.Object ) error {
353
+ func patchFieldValueToMultiple (fieldPath string , value any , to runtime.Object , mo * xpv1. MergeOptions ) error {
354
354
paved , err := fieldpath .PaveObject (to )
355
355
if err != nil {
356
356
return err
@@ -366,7 +366,7 @@ func patchFieldValueToMultiple(fieldPath string, value any, to runtime.Object) e
366
366
}
367
367
368
368
for _ , field := range arrayFieldPaths {
369
- if err := paved .SetValue (field , value ); err != nil {
369
+ if err := paved .MergeValue (field , value , mo ); err != nil {
370
370
return err
371
371
}
372
372
}
0 commit comments