@@ -195,11 +195,7 @@ const ( // They should complete the sentence "Deployment default/foo has been ..
195
195
//
196
196
// It returns the executed operation and an error.
197
197
func CreateOrUpdate (ctx context.Context , c client.Client , obj client.Object , f MutateFn ) (OperationResult , error ) {
198
- key , err := client .ObjectKeyFromObject (obj )
199
- if err != nil {
200
- return OperationResultNone , err
201
- }
202
-
198
+ key := client .ObjectKeyFromObject (obj )
203
199
if err := c .Get (ctx , key , obj ); err != nil {
204
200
if ! errors .IsNotFound (err ) {
205
201
return OperationResultNone , err
@@ -236,11 +232,7 @@ func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, f M
236
232
//
237
233
// It returns the executed operation and an error.
238
234
func CreateOrPatch (ctx context.Context , c client.Client , obj client.Object , f MutateFn ) (OperationResult , error ) {
239
- key , err := client .ObjectKeyFromObject (obj )
240
- if err != nil {
241
- return OperationResultNone , err
242
- }
243
-
235
+ key := client .ObjectKeyFromObject (obj )
244
236
if err := c .Get (ctx , key , obj ); err != nil {
245
237
if ! errors .IsNotFound (err ) {
246
238
return OperationResultNone , err
@@ -331,11 +323,11 @@ func CreateOrPatch(ctx context.Context, c client.Client, obj client.Object, f Mu
331
323
}
332
324
333
325
// mutate wraps a MutateFn and applies validation to its result
334
- func mutate (f MutateFn , key client.ObjectKey , obj runtime .Object ) error {
326
+ func mutate (f MutateFn , key client.ObjectKey , obj client .Object ) error {
335
327
if err := f (); err != nil {
336
328
return err
337
329
}
338
- if newKey , err := client .ObjectKeyFromObject (obj ); err != nil || key != newKey {
330
+ if newKey := client .ObjectKeyFromObject (obj ); key != newKey {
339
331
return fmt .Errorf ("MutateFn cannot mutate object name and/or object namespace" )
340
332
}
341
333
return nil
0 commit comments