Skip to content

Commit

Permalink
refactor predicate
Browse files Browse the repository at this point in the history
Signed-off-by: Coleen Iona Quadros <[email protected]>
  • Loading branch information
coleenquadros committed Jan 9, 2024
1 parent cc9b70a commit 8895631
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package placementrule

import (
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
"reflect"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)
Expand Down Expand Up @@ -80,9 +82,9 @@ func GetAddOnDeploymentPredicates() predicate.Funcs {
return true
},
UpdateFunc: func(e event.UpdateEvent) bool {
if e.ObjectNew.GetName() == defaultAddonDeploymentConfig.Name &&
e.ObjectNew.GetNamespace() == defaultAddonDeploymentConfig.Namespace {
log.Info("default AddonDeploymentConfig is updated")
if !reflect.DeepEqual(e.ObjectNew.(*addonv1alpha1.AddOnDeploymentConfig).Spec.ProxyConfig,
e.ObjectOld.(*addonv1alpha1.AddOnDeploymentConfig).Spec.ProxyConfig) {
log.Info("AddonDeploymentConfig is updated", e.ObjectNew.GetName(), "name", e.ObjectNew.GetNamespace(), "namespace")
return true
}
return false
Expand Down

0 comments on commit 8895631

Please sign in to comment.