@@ -77,16 +77,16 @@ func ApplyFromFieldPathPatch(p PatchInterface, from, to runtime.Object) error {
7777 return err
7878 }
7979
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-
8580 mo , err := toMergeOption (p )
8681 if err != nil {
8782 return err
8883 }
8984
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+
9090 return errors .Wrap (patchFieldValueToObject (p .GetToFieldPath (), out , to , mo ), "cannot patch to object" )
9191}
9292
@@ -350,7 +350,7 @@ func patchFieldValueToObject(fieldPath string, value any, to runtime.Object, mo
350350// patchFieldValueToMultiple, given a path with wildcards in an array index,
351351// expands the arrays paths in the "to" object and patches the value into each
352352// 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 {
354354 paved , err := fieldpath .PaveObject (to )
355355 if err != nil {
356356 return err
@@ -366,7 +366,7 @@ func patchFieldValueToMultiple(fieldPath string, value any, to runtime.Object) e
366366 }
367367
368368 for _ , field := range arrayFieldPaths {
369- if err := paved .SetValue (field , value ); err != nil {
369+ if err := paved .MergeValue (field , value , mo ); err != nil {
370370 return err
371371 }
372372 }
0 commit comments