Skip to content

Commit

Permalink
Merge pull request #2705 from avorima/use-maps
Browse files Browse the repository at this point in the history
🌱 Compare labels and annotations using maps.Equal
  • Loading branch information
k8s-ci-robot authored Mar 13, 2024
2 parents 1382d7d + a4a0164 commit cb5107b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/predicate/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package predicate

import (
"reflect"
"maps"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -198,7 +198,7 @@ func (AnnotationChangedPredicate) Update(e event.UpdateEvent) bool {
return false
}

return !reflect.DeepEqual(e.ObjectNew.GetAnnotations(), e.ObjectOld.GetAnnotations())
return !maps.Equal(e.ObjectNew.GetAnnotations(), e.ObjectOld.GetAnnotations())
}

// LabelChangedPredicate implements a default update predicate function on label change.
Expand Down Expand Up @@ -229,7 +229,7 @@ func (LabelChangedPredicate) Update(e event.UpdateEvent) bool {
return false
}

return !reflect.DeepEqual(e.ObjectNew.GetLabels(), e.ObjectOld.GetLabels())
return !maps.Equal(e.ObjectNew.GetLabels(), e.ObjectOld.GetLabels())
}

// And returns a composite predicate that implements a logical AND of the predicates passed to it.
Expand Down

0 comments on commit cb5107b

Please sign in to comment.