mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 09:36:58 +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
|
codec runtime.ParameterCodec
|
||||||
annotationFilter string
|
annotationFilter string
|
||||||
labelSelector labels.Selector
|
labelSelector labels.Selector
|
||||||
informer *cache.SharedInformer
|
informer cache.SharedInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
func addKnownTypes(scheme *runtime.Scheme, groupVersion schema.GroupVersion) error {
|
func addKnownTypes(scheme *runtime.Scheme, groupVersion schema.GroupVersion) error {
|
||||||
@ -123,7 +123,7 @@ func NewCRDSource(crdClient rest.Interface, namespace, kind string, annotationFi
|
|||||||
if startInformer {
|
if startInformer {
|
||||||
// external-dns already runs its sync-handler periodically (controlled by `--interval` flag) to ensure any
|
// 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.
|
// 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{
|
&cache.ListWatch{
|
||||||
ListWithContextFunc: func(ctx context.Context, lo metav1.ListOptions) (runtime.Object, error) {
|
ListWithContextFunc: func(ctx context.Context, lo metav1.ListOptions) (runtime.Object, error) {
|
||||||
return sourceCrd.List(ctx, &lo)
|
return sourceCrd.List(ctx, &lo)
|
||||||
@ -134,8 +134,7 @@ func NewCRDSource(crdClient rest.Interface, namespace, kind string, annotationFi
|
|||||||
},
|
},
|
||||||
&apiv1alpha1.DNSEndpoint{},
|
&apiv1alpha1.DNSEndpoint{},
|
||||||
0)
|
0)
|
||||||
sourceCrd.informer = &informer
|
go sourceCrd.informer.Run(wait.NeverStop)
|
||||||
go informer.Run(wait.NeverStop)
|
|
||||||
}
|
}
|
||||||
return &sourceCrd, nil
|
return &sourceCrd, nil
|
||||||
}
|
}
|
||||||
@ -145,8 +144,7 @@ func (cs *crdSource) AddEventHandler(_ context.Context, handler func()) {
|
|||||||
log.Debug("Adding event handler for CRD")
|
log.Debug("Adding event handler for CRD")
|
||||||
// Right now there is no way to remove event handler from informer, see:
|
// Right now there is no way to remove event handler from informer, see:
|
||||||
// https://github.com/kubernetes/kubernetes/issues/79610
|
// https://github.com/kubernetes/kubernetes/issues/79610
|
||||||
informer := *cs.informer
|
_, _ = cs.informer.AddEventHandler(
|
||||||
_, _ = informer.AddEventHandler(
|
|
||||||
cache.ResourceEventHandlerFuncs{
|
cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) {
|
AddFunc: func(obj interface{}) {
|
||||||
handler()
|
handler()
|
||||||
@ -190,11 +188,9 @@ func (cs *crdSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
|||||||
|
|
||||||
illegalTarget := false
|
illegalTarget := false
|
||||||
for _, target := range ep.Targets {
|
for _, target := range ep.Targets {
|
||||||
if ep.RecordType != endpoint.RecordTypeNAPTR && strings.HasSuffix(target, ".") {
|
isNAPTR := ep.RecordType == endpoint.RecordTypeNAPTR
|
||||||
illegalTarget = true
|
hasDot := strings.HasSuffix(target, ".")
|
||||||
break
|
if (isNAPTR && !hasDot) || (!isNAPTR && hasDot) {
|
||||||
}
|
|
||||||
if ep.RecordType == endpoint.RecordTypeNAPTR && !strings.HasSuffix(target, ".") {
|
|
||||||
illegalTarget = true
|
illegalTarget = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -736,7 +736,7 @@ func helperCreateWatcherWithInformer(t *testing.T) (*cachetesting.FakeController
|
|||||||
}, time.Second, 10*time.Millisecond)
|
}, time.Second, 10*time.Millisecond)
|
||||||
|
|
||||||
cs := &crdSource{
|
cs := &crdSource{
|
||||||
informer: &informer,
|
informer: informer,
|
||||||
}
|
}
|
||||||
|
|
||||||
return watcher, *cs
|
return watcher, *cs
|
||||||
|
Loading…
Reference in New Issue
Block a user