Skip to content

Commit

Permalink
Merge pull request #2812 from inteon/make_ResourceVersionChangedPredi…
Browse files Browse the repository at this point in the history
…cate_generic

✨ Add missing generic version of ResourceVersionChangedPredicate
  • Loading branch information
k8s-ci-robot authored Aug 5, 2024
2 parents 441d11f + a2e9eb7 commit 242abfb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/predicate/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,20 @@ func NewTypedPredicateFuncs[object any](filter func(object object) bool) TypedFu
}

// ResourceVersionChangedPredicate implements a default update predicate function on resource version change.
type ResourceVersionChangedPredicate struct {
Funcs
type ResourceVersionChangedPredicate = TypedResourceVersionChangedPredicate[client.Object]

// TypedResourceVersionChangedPredicate implements a default update predicate function on resource version change.
type TypedResourceVersionChangedPredicate[T metav1.Object] struct {
TypedFuncs[T]
}

// Update implements default UpdateEvent filter for validating resource version change.
func (ResourceVersionChangedPredicate) Update(e event.UpdateEvent) bool {
if e.ObjectOld == nil {
func (TypedResourceVersionChangedPredicate[T]) Update(e event.TypedUpdateEvent[T]) bool {
if isNil(e.ObjectOld) {
log.Error(nil, "Update event has no old object to update", "event", e)
return false
}
if e.ObjectNew == nil {
if isNil(e.ObjectNew) {
log.Error(nil, "Update event has no new object to update", "event", e)
return false
}
Expand Down

0 comments on commit 242abfb

Please sign in to comment.