Skip to content

Commit

Permalink
controller: single propagation of delta events
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Cassolato <[email protected]>
  • Loading branch information
guicassolato committed Aug 29, 2024
1 parent e963418 commit e425713
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,27 +222,20 @@ func (c *Controller) add(obj Object) {
defer c.Unlock()

c.cache.Add(obj)
c.propagate([]ResourceEvent{{obj.GetObjectKind().GroupVersionKind().GroupKind(), CreateEvent, nil, obj}})
}

func (c *Controller) update(oldObj, newObj Object) {
func (c *Controller) update(_, newObj Object) {
c.Lock()
defer c.Unlock()

if oldObj.GetGeneration() == newObj.GetGeneration() {
return
}

c.cache.Add(newObj)
c.propagate([]ResourceEvent{{newObj.GetObjectKind().GroupVersionKind().GroupKind(), UpdateEvent, oldObj, newObj}})
}

func (c *Controller) delete(obj Object) {
c.Lock()
defer c.Unlock()

c.cache.Delete(obj)
c.propagate([]ResourceEvent{{obj.GetObjectKind().GroupVersionKind().GroupKind(), DeleteEvent, obj, nil}})
}

func (c *Controller) propagate(resourceEvents []ResourceEvent) {
Expand Down

0 comments on commit e425713

Please sign in to comment.