Skip to content

Commit

Permalink
✨ Add controllerutil.ServerSideApply utility function
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <vincepri@vmware.com>
  • Loading branch information
vincepri committed May 26, 2020
1 parent c45adcf commit f180879
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/controller/controllerutil/controllerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,9 @@ type Object interface {
metav1.Object
runtime.Object
}

// ServerSideApply peforms a Patch using client.Apply as strategy and forcing ownership in case of conflicts.
func ServerSideApply(ctx context.Context, c client.Client, owner client.FieldOwner, obj Object, opts ...client.PatchOption) error {
opts = append([]client.PatchOption{client.ForceOwnership, owner}, opts...)
return c.Patch(ctx, obj, client.Apply, opts...)
}

0 comments on commit f180879

Please sign in to comment.