mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 17:46:57 +02:00
Address review comment
This commit is contained in:
parent
683663e9c2
commit
4745ddbb0e
@ -76,11 +76,6 @@ func NewNodeSource(ctx context.Context, kubeClient kubernetes.Interface, annotat
|
||||
}, nil
|
||||
}
|
||||
|
||||
type endpointsKey struct {
|
||||
dnsName string
|
||||
recordType string
|
||||
}
|
||||
|
||||
// Endpoints returns endpoint objects for each service that should be processed.
|
||||
func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error) {
|
||||
nodes, err := ns.nodeInformer.Lister().List(labels.Everything())
|
||||
@ -93,7 +88,7 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
endpoints := map[endpointsKey]*endpoint.Endpoint{}
|
||||
endpoints := map[endpointKey]*endpoint.Endpoint{}
|
||||
|
||||
// create endpoints for all nodes
|
||||
for _, node := range nodes {
|
||||
@ -141,7 +136,7 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
|
||||
ep.Labels = endpoint.NewLabels()
|
||||
for _, addr := range addrs {
|
||||
log.Debugf("adding endpoint %s target %s", ep, addr)
|
||||
key := endpointsKey{
|
||||
key := endpointKey{
|
||||
dnsName: ep.DNSName,
|
||||
recordType: suitableType(addr),
|
||||
}
|
||||
|
@ -76,11 +76,6 @@ func NewPodSource(ctx context.Context, kubeClient kubernetes.Interface, namespac
|
||||
func (*podSource) AddEventHandler(ctx context.Context, handler func()) {
|
||||
}
|
||||
|
||||
type endpointKey struct {
|
||||
domain string
|
||||
recordType string
|
||||
}
|
||||
|
||||
func (ps *podSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error) {
|
||||
pods, err := ps.podInformer.Lister().Pods(ps.namespace).List(labels.Everything())
|
||||
if err != nil {
|
||||
@ -128,14 +123,14 @@ func (ps *podSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
|
||||
}
|
||||
endpoints := []*endpoint.Endpoint{}
|
||||
for key, targets := range endpointMap {
|
||||
endpoints = append(endpoints, endpoint.NewEndpoint(key.domain, key.recordType, targets...))
|
||||
endpoints = append(endpoints, endpoint.NewEndpoint(key.dnsName, key.recordType, targets...))
|
||||
}
|
||||
return endpoints, nil
|
||||
}
|
||||
|
||||
func addToEndpointMap(endpointMap map[endpointKey][]string, domain string, recordType string, address string) {
|
||||
key := endpointKey{
|
||||
domain: domain,
|
||||
dnsName: domain,
|
||||
recordType: recordType,
|
||||
}
|
||||
if _, ok := endpointMap[key]; !ok {
|
||||
|
@ -86,6 +86,12 @@ type Source interface {
|
||||
AddEventHandler(context.Context, func())
|
||||
}
|
||||
|
||||
// endpointKey is the type of a map key for separating endpoints or targets.
|
||||
type endpointKey struct {
|
||||
dnsName string
|
||||
recordType string
|
||||
}
|
||||
|
||||
func getTTLFromAnnotations(annotations map[string]string) (endpoint.TTL, error) {
|
||||
ttlNotConfigured := endpoint.TTL(0)
|
||||
ttlAnnotation, exists := annotations[ttlAnnotationKey]
|
||||
|
Loading…
Reference in New Issue
Block a user