@@ -3,19 +3,15 @@ package controller
33import (
44 "context"
55 "fmt"
6- "reflect"
76 "strings"
87
98 "github.com/api7/api7-ingress-controller/internal/controller/config"
10- "github.com/api7/gopkg/pkg/log"
119 "github.com/samber/lo"
1210 corev1 "k8s.io/api/core/v1"
1311 networkingv1 "k8s.io/api/networking/v1"
1412 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1513 "k8s.io/apimachinery/pkg/labels"
1614 "sigs.k8s.io/controller-runtime/pkg/client"
17- "sigs.k8s.io/controller-runtime/pkg/event"
18- "sigs.k8s.io/controller-runtime/pkg/predicate"
1915 "sigs.k8s.io/controller-runtime/pkg/reconcile"
2016 gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
2117)
@@ -763,40 +759,3 @@ func SplitMetaNamespaceKey(key string) (namespace, name string, err error) {
763759
764760 return "" , "" , fmt .Errorf ("unexpected key format: %q" , key )
765761}
766-
767- type CombinedPredicate struct {
768- predicate.GenerationChangedPredicate
769- }
770-
771- func (c CombinedPredicate ) Update (e event.UpdateEvent ) bool {
772- if isNil (e .ObjectOld ) {
773- log .Debugw ("Update event has no old object for update" )
774- return false
775- }
776- if isNil (e .ObjectNew ) {
777- log .Debugw ("Update event has no new object for update" )
778- return false
779- }
780-
781- _ , ok := e .ObjectNew .(* networkingv1.IngressClass )
782- if ok {
783- log .Debugw ("IngressClass update event" )
784- return true
785- }
786-
787- log .Debugw ("other update event" )
788- // if the object is not IngressClass, return the result of GenerationChangedPredicate.Update
789- return c .GenerationChangedPredicate .Update (e )
790- }
791-
792- func isNil (arg any ) bool {
793- if v := reflect .ValueOf (arg ); ! v .IsValid () || ((v .Kind () == reflect .Ptr ||
794- v .Kind () == reflect .Interface ||
795- v .Kind () == reflect .Slice ||
796- v .Kind () == reflect .Map ||
797- v .Kind () == reflect .Chan ||
798- v .Kind () == reflect .Func ) && v .IsNil ()) {
799- return true
800- }
801- return false
802- }
0 commit comments