mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 17:16:59 +02:00
fix(source): use NewEndpointWithTTL and omit nil Endpoints
This commit is contained in:
parent
6cf4783a07
commit
36a6e19dd5
@ -284,52 +284,41 @@ func endpointsForHostname(hostname string, targets endpoint.Targets, ttl endpoin
|
||||
}
|
||||
|
||||
if len(aTargets) > 0 {
|
||||
epA := &endpoint.Endpoint{
|
||||
DNSName: strings.TrimSuffix(hostname, "."),
|
||||
Targets: aTargets,
|
||||
RecordTTL: ttl,
|
||||
RecordType: endpoint.RecordTypeA,
|
||||
Labels: endpoint.NewLabels(),
|
||||
ProviderSpecific: providerSpecific,
|
||||
SetIdentifier: setIdentifier,
|
||||
epA := endpoint.NewEndpointWithTTL(hostname, endpoint.RecordTypeA, ttl, aTargets...)
|
||||
if epA != nil {
|
||||
epA.ProviderSpecific = providerSpecific
|
||||
epA.SetIdentifier = setIdentifier
|
||||
if resource != "" {
|
||||
epA.Labels[endpoint.ResourceLabelKey] = resource
|
||||
}
|
||||
endpoints = append(endpoints, epA)
|
||||
}
|
||||
if resource != "" {
|
||||
epA.Labels[endpoint.ResourceLabelKey] = resource
|
||||
}
|
||||
endpoints = append(endpoints, epA)
|
||||
}
|
||||
|
||||
if len(aaaaTargets) > 0 {
|
||||
epAAAA := &endpoint.Endpoint{
|
||||
DNSName: strings.TrimSuffix(hostname, "."),
|
||||
Targets: aaaaTargets,
|
||||
RecordTTL: ttl,
|
||||
RecordType: endpoint.RecordTypeAAAA,
|
||||
Labels: endpoint.NewLabels(),
|
||||
ProviderSpecific: providerSpecific,
|
||||
SetIdentifier: setIdentifier,
|
||||
epAAAA := endpoint.NewEndpointWithTTL(hostname, endpoint.RecordTypeAAAA, ttl, aaaaTargets...)
|
||||
if epAAAA != nil {
|
||||
epAAAA.ProviderSpecific = providerSpecific
|
||||
epAAAA.SetIdentifier = setIdentifier
|
||||
if resource != "" {
|
||||
epAAAA.Labels[endpoint.ResourceLabelKey] = resource
|
||||
}
|
||||
endpoints = append(endpoints, epAAAA)
|
||||
}
|
||||
if resource != "" {
|
||||
epAAAA.Labels[endpoint.ResourceLabelKey] = resource
|
||||
}
|
||||
endpoints = append(endpoints, epAAAA)
|
||||
}
|
||||
|
||||
if len(cnameTargets) > 0 {
|
||||
epCNAME := &endpoint.Endpoint{
|
||||
DNSName: strings.TrimSuffix(hostname, "."),
|
||||
Targets: cnameTargets,
|
||||
RecordTTL: ttl,
|
||||
RecordType: endpoint.RecordTypeCNAME,
|
||||
Labels: endpoint.NewLabels(),
|
||||
ProviderSpecific: providerSpecific,
|
||||
SetIdentifier: setIdentifier,
|
||||
epCNAME := endpoint.NewEndpointWithTTL(hostname, endpoint.RecordTypeCNAME, ttl, cnameTargets...)
|
||||
if epCNAME != nil {
|
||||
epCNAME.ProviderSpecific = providerSpecific
|
||||
epCNAME.SetIdentifier = setIdentifier
|
||||
if resource != "" {
|
||||
epCNAME.Labels[endpoint.ResourceLabelKey] = resource
|
||||
}
|
||||
endpoints = append(endpoints, epCNAME)
|
||||
}
|
||||
if resource != "" {
|
||||
epCNAME.Labels[endpoint.ResourceLabelKey] = resource
|
||||
}
|
||||
endpoints = append(endpoints, epCNAME)
|
||||
}
|
||||
|
||||
return endpoints
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user