mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 17:16:59 +02:00
chore(codebase): remove pointer to an interface (#5625)
* chore(codebase): remove pointer to an interface Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com> * chore(codebase): simplify logic Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com> --------- Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
parent
1eccb64bcb
commit
5d8d424bcb
@ -51,7 +51,7 @@ type crdSource struct {
|
||||
codec runtime.ParameterCodec
|
||||
annotationFilter string
|
||||
labelSelector labels.Selector
|
||||
informer *cache.SharedInformer
|
||||
informer cache.SharedInformer
|
||||
}
|
||||
|
||||
func addKnownTypes(scheme *runtime.Scheme, groupVersion schema.GroupVersion) error {
|
||||
@ -123,7 +123,7 @@ func NewCRDSource(crdClient rest.Interface, namespace, kind string, annotationFi
|
||||
if startInformer {
|
||||
// external-dns already runs its sync-handler periodically (controlled by `--interval` flag) to ensure any
|
||||
// missed or dropped events are handled. specify resync period 0 to avoid unnecessary sync handler invocations.
|
||||
informer := cache.NewSharedInformer(
|
||||
sourceCrd.informer = cache.NewSharedInformer(
|
||||
&cache.ListWatch{
|
||||
ListWithContextFunc: func(ctx context.Context, lo metav1.ListOptions) (runtime.Object, error) {
|
||||
return sourceCrd.List(ctx, &lo)
|
||||
@ -134,8 +134,7 @@ func NewCRDSource(crdClient rest.Interface, namespace, kind string, annotationFi
|
||||
},
|
||||
&apiv1alpha1.DNSEndpoint{},
|
||||
0)
|
||||
sourceCrd.informer = &informer
|
||||
go informer.Run(wait.NeverStop)
|
||||
go sourceCrd.informer.Run(wait.NeverStop)
|
||||
}
|
||||
return &sourceCrd, nil
|
||||
}
|
||||
@ -145,8 +144,7 @@ func (cs *crdSource) AddEventHandler(_ context.Context, handler func()) {
|
||||
log.Debug("Adding event handler for CRD")
|
||||
// Right now there is no way to remove event handler from informer, see:
|
||||
// https://github.com/kubernetes/kubernetes/issues/79610
|
||||
informer := *cs.informer
|
||||
_, _ = informer.AddEventHandler(
|
||||
_, _ = cs.informer.AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
handler()
|
||||
@ -190,11 +188,9 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
||||
|
||||
illegalTarget := false
|
||||
for _, target := range ep.Targets {
|
||||
if ep.RecordType != endpoint.RecordTypeNAPTR && strings.HasSuffix(target, ".") {
|
||||
illegalTarget = true
|
||||
break
|
||||
}
|
||||
if ep.RecordType == endpoint.RecordTypeNAPTR && !strings.HasSuffix(target, ".") {
|
||||
isNAPTR := ep.RecordType == endpoint.RecordTypeNAPTR
|
||||
hasDot := strings.HasSuffix(target, ".")
|
||||
if (isNAPTR && !hasDot) || (!isNAPTR && hasDot) {
|
||||
illegalTarget = true
|
||||
break
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ func helperCreateWatcherWithInformer(t *testing.T) (*cachetesting.FakeController
|
||||
}, time.Second, 10*time.Millisecond)
|
||||
|
||||
cs := &crdSource{
|
||||
informer: &informer,
|
||||
informer: informer,
|
||||
}
|
||||
|
||||
return watcher, *cs
|
||||
|
Loading…
Reference in New Issue
Block a user