provider/infoblox.go
func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error) {
	zones, err := p.zones()
	if err != nil {
		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{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objA, "", &resA)
		if err != nil {
			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))
		}

		// Include Host records since they should be treated synonymously with A records
		var resH []ibclient.HostRecord
		objH := ibclient.NewHostRecord(
			ibclient.HostRecord{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objH, "", &resH)
		if err != nil {
			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 {
				endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeA, ip.Ipv4Addr))
			}
		}

		var resC []ibclient.RecordCNAME
		objC := ibclient.NewRecordCNAME(
			ibclient.RecordCNAME{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objC, "", &resC)
		if err != nil {
			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))
		}

		var resT []ibclient.RecordTXT
		objT := ibclient.NewRecordTXT(
			ibclient.RecordTXT{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objT, "", &resT)
		if err != nil {
			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.
			// Unhandled, the missing double quotes would break the extractOwnerID method of the registry package.
			if _, err := strconv.Unquote(res.Text); err != nil {
				res.Text = strconv.Quote(res.Text)
			}
			endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeTXT, res.Text))
		}
	}
	logrus.Debugf("fetched %d records from infoblox", len(endpoints))
	return endpoints, nil
}
func (p *InfobloxProvider) Records() (endpoints []*endpoint.Endpoint, err error) {
	zones, err := p.zones()
	if err != nil {
		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{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objA, "", &resA)
		if err != nil {
			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))
		}

		// Include Host records since they should be treated synonymously with A records
		var resH []ibclient.HostRecord
		objH := ibclient.NewHostRecord(
			ibclient.HostRecord{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objH, "", &resH)
		if err != nil {
			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 {
				endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeA, ip.Ipv4Addr))
			}
		}

		var resC []ibclient.RecordCNAME
		objC := ibclient.NewRecordCNAME(
			ibclient.RecordCNAME{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objC, "", &resC)
		if err != nil {
			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))
		}

		var resT []ibclient.RecordTXT
		objT := ibclient.NewRecordTXT(
			ibclient.RecordTXT{
				Zone: zone.Fqdn,
				View: p.view,
			},
		)
		err = p.client.GetObject(objT, "", &resT)
		if err != nil {
			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.
			// Unhandled, the missing double quotes would break the extractOwnerID method of the registry package.
			if _, err := strconv.Unquote(res.Text); err != nil {
				res.Text = strconv.Quote(res.Text)
			}
			endpoints = append(endpoints, endpoint.NewEndpoint(res.Name, endpoint.RecordTypeTXT, res.Text))
		}
	}
	logrus.Debugf("fetched %d records from infoblox", len(endpoints))
	return endpoints, nil
}
func ( p * InfobloxProvider ) Records ( ) ( endpoints [ ] * endpoint . Endpoint , err error ) { zones , err := p . zones ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } for _ , zone := range zones { logrus . Debugf ( " " , zone . Fqdn ) var resA [ ] ibclient . RecordA objA := ibclient . NewRecordA ( ibclient . RecordA { Zone : zone . Fqdn , View : p . view , } , ) err = p . client . GetObject ( objA , " " , & resA ) if err != nil { return nil , fmt . Errorf ( " " , zone . Fqdn , err ) } for _ , res := range resA { endpoints = append ( endpoints , endpoint . NewEndpoint ( res . Name , endpoint . RecordTypeA , res . Ipv4Addr ) ) } // Include Host records since they should be treated synonymously with A records var resH [ ] ibclient . HostRecord objH := ibclient . NewHostRecord ( ibclient . HostRecord { Zone : zone . Fqdn , View : p . view , } , ) err = p . client . GetObject ( objH , " " , & resH ) if err != nil { return nil , fmt . Errorf ( " " , zone . Fqdn , err ) } for _ , res := range resH { for _ , ip := range res . Ipv4Addrs { endpoints = append ( endpoints , endpoint . NewEndpoint ( res . Name , endpoint . RecordTypeA , ip . Ipv4Addr ) ) } } var resC [ ] ibclient . RecordCNAME objC := ibclient . NewRecordCNAME ( ibclient . RecordCNAME { Zone : zone . Fqdn , View : p . view , } , ) err = p . client . GetObject ( objC , " " , & resC ) if err != nil { return nil , fmt . Errorf ( " " , zone . Fqdn , err ) } for _ , res := range resC { endpoints = append ( endpoints , endpoint . NewEndpoint ( res . Name , endpoint . RecordTypeCNAME , res . Canonical ) ) } var resT [ ] ibclient . RecordTXT objT := ibclient . NewRecordTXT ( ibclient . RecordTXT { Zone : zone . Fqdn , View : p . view , } , ) err = p . client . GetObject ( objT , " " , & resT ) if err != nil { return nil , fmt . Errorf ( " " , zone . Fqdn , err ) } for _ , res := range resT { // The Infoblox API strips enclosing double quotes from TXT records lacking whitespace. // Unhandled, the missing double quotes would break the extractOwnerID method of the registry package. if _ , err := strconv . Unquote ( res . Text ) ; err != nil { res . Text = strconv . Quote ( res . Text ) } endpoints = append ( endpoints , endpoint . NewEndpoint ( res . Name , endpoint . RecordTypeTXT , res . Text ) ) } } logrus . Debugf ( " " , len ( endpoints ) ) return endpoints , nil }
// Records gets the current records.
Records gets the current records .