Skip to content

Commit

Permalink
add missing generic version of ResourceVersionChangedPredicate
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed May 4, 2024
1 parent 9bc967a commit e3d87d7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/predicate/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Check failure on line 148 in pkg/predicate/predicate.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported type ResourceVersionChangedPredicate should be of the form "ResourceVersionChangedPredicate ..." (with optional leading article) (revive)

Check warning on line 148 in pkg/predicate/predicate.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported type ResourceVersionChangedPredicate should be of the form "ResourceVersionChangedPredicate ..." (with optional leading article) (revive)
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 e3d87d7

Please sign in to comment.