Skip to content

Commit

Permalink
only update when obj is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
Daishan Peng committed Feb 2, 2018
1 parent 151aa66 commit ad472c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lifecycle/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ func (o *objectLifecycleAdapter) sync(key string, obj runtime.Object) error {

copyObj := obj.DeepCopyObject()
newObj, err := o.lifecycle.Updated(copyObj)
o.update(metadata.GetName(), obj, newObj)
if newObj != nil {
o.update(metadata.GetName(), obj, newObj)
}
return err
}

Expand All @@ -82,7 +84,9 @@ func (o *objectLifecycleAdapter) finalize(metadata metav1.Object, obj runtime.Ob

copyObj := obj.DeepCopyObject()
if newObj, err := o.lifecycle.Finalize(copyObj); err != nil {
o.update(metadata.GetName(), obj, newObj)
if newObj != nil {
o.update(metadata.GetName(), obj, newObj)
}
return false, err
} else if newObj != nil {
copyObj = newObj
Expand Down

0 comments on commit ad472c4

Please sign in to comment.