Skip to content

Commit

Permalink
Drop Not predicate util function in favor of controller-runtime `pr…
Browse files Browse the repository at this point in the history
…edicate.Not`
  • Loading branch information
shafeeqes committed Jan 11, 2023
1 parent d61afb7 commit 667c0bb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 43 deletions.
18 changes: 0 additions & 18 deletions pkg/controllerutils/predicate/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,6 @@ func HasName(name string) predicate.Predicate {
})
}

// Not inverts the passed predicate.
func Not(p predicate.Predicate) predicate.Predicate {
return predicate.Funcs{
CreateFunc: func(event event.CreateEvent) bool {
return !p.Create(event)
},
UpdateFunc: func(event event.UpdateEvent) bool {
return !p.Update(event)
},
GenericFunc: func(event event.GenericEvent) bool {
return !p.Generic(event)
},
DeleteFunc: func(event event.DeleteEvent) bool {
return !p.Delete(event)
},
}
}

// EventType is an alias for byte.
type EventType byte

Expand Down
24 changes: 0 additions & 24 deletions pkg/controllerutils/predicate/predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,6 @@ var _ = Describe("Predicate", func() {
})
})

Describe("#Not", func() {
It("should invert predicate", func() {
predicate := Not(predicate.Funcs{
CreateFunc: func(_ event.CreateEvent) bool {
return true
},
UpdateFunc: func(_ event.UpdateEvent) bool {
return true
},
GenericFunc: func(_ event.GenericEvent) bool {
return true
},
DeleteFunc: func(_ event.DeleteEvent) bool {
return true
},
})

gomega.Expect(predicate.Create(event.CreateEvent{})).To(gomega.BeFalse())
gomega.Expect(predicate.Update(event.UpdateEvent{})).To(gomega.BeFalse())
gomega.Expect(predicate.Delete(event.DeleteEvent{})).To(gomega.BeFalse())
gomega.Expect(predicate.Generic(event.GenericEvent{})).To(gomega.BeFalse())
})
})

DescribeTable("#ForEventTypes",
func(events []EventType, createMatcher, updateMatcher, deleteMatcher, genericMatcher gomegatypes.GomegaMatcher) {
p := ForEventTypes(events...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/controller/shoot/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (r *Reconciler) AddToManager(mgr manager.Manager) error {
Named(ControllerName).
For(&gardencorev1beta1.Shoot{}, builder.WithPredicates(
r.ShootPredicate(),
predicateutils.Not(predicateutils.IsDeleting()),
predicate.Not(predicateutils.IsDeleting()),
)).
WithOptions(controller.Options{
MaxConcurrentReconciles: r.Config.ConcurrentSyncs,
Expand Down

0 comments on commit 667c0bb

Please sign in to comment.