@@ -270,6 +270,9 @@ const ( // They should complete the sentence "Deployment default/foo has been ..
270
270
// The MutateFn is called regardless of creating or updating an object.
271
271
//
272
272
// It returns the executed operation and an error.
273
+ //
274
+ // Note: changes made by MutateFn to any sub-resource (status...), will be
275
+ // discarded.
273
276
func CreateOrUpdate (ctx context.Context , c client.Client , obj client.Object , f MutateFn ) (OperationResult , error ) {
274
277
key := client .ObjectKeyFromObject (obj )
275
278
if err := c .Get (ctx , key , obj ); err != nil {
@@ -307,6 +310,12 @@ func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, f M
307
310
// The MutateFn is called regardless of creating or updating an object.
308
311
//
309
312
// It returns the executed operation and an error.
313
+ //
314
+ // Note: changes to any sub-resource other than status will be ignored.
315
+ // Changes to the status sub-resource will only be applied if the object
316
+ // already exist. To change the status on object creation, the easiest
317
+ // way is to requeue the object in the controller if OperationResult is
318
+ // OperationResultCreated
310
319
func CreateOrPatch (ctx context.Context , c client.Client , obj client.Object , f MutateFn ) (OperationResult , error ) {
311
320
key := client .ObjectKeyFromObject (obj )
312
321
if err := c .Get (ctx , key , obj ); err != nil {
0 commit comments