From e3d87d721e2036193076ca7afdd815fc287f3ace Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Sat, 4 May 2024 13:29:46 +0200 Subject: [PATCH] add missing generic version of ResourceVersionChangedPredicate Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- pkg/predicate/predicate.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/predicate/predicate.go b/pkg/predicate/predicate.go index f74889d1cc..e3a82f34d1 100644 --- a/pkg/predicate/predicate.go +++ b/pkg/predicate/predicate.go @@ -145,18 +145,21 @@ func NewTypedPredicateFuncs[T any](filter func(object T) bool) TypedFuncs[T] { } } -// ResourceVersionChangedPredicate implements a default update predicate function on resource version change. -type ResourceVersionChangedPredicate struct { - Funcs +// GenerationChangedPredicate implements a default update predicate function on resource version change. +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 }