mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-05-04 22:26:11 +02:00
Merge pull request #785 from dsbrng25b/master
Improve errors in Records() of infoblox provider
This commit is contained in:
commit
aa9e7df1dd
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package provider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -95,10 +96,11 @@ func NewInfobloxProvider(infobloxConfig InfobloxConfig) (*InfobloxProvider, erro
|
||||
func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error) {
|
||||
zones, err := p.zones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("could not fetch zones: %s", err)
|
||||
}
|
||||
|
||||
for _, zone := range zones {
|
||||
logrus.Debugf("fetch records from zone '%s'", zone.Fqdn)
|
||||
var resA []ibclient.RecordA
|
||||
objA := ibclient.NewRecordA(
|
||||
ibclient.RecordA{
|
||||
@ -107,7 +109,7 @@ func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error)
|
||||
)
|
||||
err = p.client.GetObject(objA, "", &resA)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("could not fetch A records from zone '%s': %s", zone.Fqdn, err)
|
||||
}
|
||||
for _, res := range resA {
|
||||
endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeA, res.Ipv4Addr))
|
||||
@ -122,7 +124,7 @@ func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error)
|
||||
)
|
||||
err = p.client.GetObject(objH, "", &resH)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("could not fetch host records from zone '%s': %s", zone.Fqdn, err)
|
||||
}
|
||||
for _, res := range resH {
|
||||
for _, ip := range res.Ipv4Addrs {
|
||||
@ -138,7 +140,7 @@ func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error)
|
||||
)
|
||||
err = p.client.GetObject(objC, "", &resC)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("could not fetch CNAME records from zone '%s': %s", zone.Fqdn, err)
|
||||
}
|
||||
for _, res := range resC {
|
||||
endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeCNAME, res.Canonical))
|
||||
@ -152,7 +154,7 @@ func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error)
|
||||
)
|
||||
err = p.client.GetObject(objT, "", &resT)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("could not fetch TXT records from zone '%s': %s", zone.Fqdn, err)
|
||||
}
|
||||
for _, res := range resT {
|
||||
// The Infoblox API strips enclosing double quotes from TXT records lacking whitespace.
|
||||
@ -163,6 +165,7 @@ func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error)
|
||||
endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeTXT, res.Text))
|
||||
}
|
||||
}
|
||||
logrus.Debugf("fetched %d records from infoblox", len(endpoints))
|
||||
return endpoints, nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user