@@ -356,6 +356,28 @@ func (c *fakeDynamicResourceClient) Watch(ctx context.Context, opts metav1.ListO
356356}
357357
358358func (c * fakeDynamicResourceClient ) Patch (ctx context.Context , name string , pt types.PatchType , data []byte , options metav1.PatchOptions , subresources ... string ) (* unstructured.Unstructured , error ) {
359+ // Handle ApplyPatchType by redirecting to Apply method which has proper SSA conflict handling
360+ if pt == types .ApplyPatchType {
361+ // Convert patch data to unstructured object
362+ var obj unstructured.Unstructured
363+ if err := json .Unmarshal (data , & obj ); err != nil {
364+ return nil , fmt .Errorf ("failed to unmarshal apply patch data: %w" , err )
365+ }
366+
367+ // Convert PatchOptions to ApplyOptions
368+ applyOptions := metav1.ApplyOptions {
369+ FieldManager : options .FieldManager ,
370+ DryRun : options .DryRun ,
371+ }
372+ if options .Force != nil {
373+ applyOptions .Force = * options .Force
374+ }
375+
376+ // Use Apply method for proper SSA handling
377+ return c .Apply (ctx , name , & obj , applyOptions , subresources ... )
378+ }
379+
380+ // For other patch types, delegate to upstream client
359381 return c .client .FakeDynamicClient .Resource (c .resource ).Namespace (c .namespace ).Patch (ctx , name , pt , data , options , subresources ... )
360382}
361383
0 commit comments