@@ -27,7 +27,7 @@ import (
27
27
"strings"
28
28
29
29
transform "github.com/StackExchange/dnscontrol/pkg/transform"
30
- ibclient "github.com/infobloxopen/infoblox-go-client"
30
+ ibclient "github.com/infobloxopen/infoblox-go-client/v2 "
31
31
"github.com/sirupsen/logrus"
32
32
33
33
"sigs.k8s.io/external-dns/endpoint"
@@ -40,6 +40,11 @@ const (
40
40
providerSpecificInfobloxPtrRecord = "infoblox-ptr-record-exists"
41
41
)
42
42
43
+ func isNotFoundError (err error ) bool {
44
+ _ , ok := err .(* ibclient.NotFoundError )
45
+ return ok
46
+ }
47
+
43
48
// InfobloxConfig clarifies the method signature
44
49
type InfobloxConfig struct {
45
50
DomainFilter endpoint.DomainFilter
@@ -95,7 +100,7 @@ func NewExtendedRequestBuilder(maxResults int, fqdnRegEx string) *ExtendedReques
95
100
96
101
// BuildRequest prepares the api request. it uses BuildRequest of
97
102
// WapiRequestBuilder and then add the _max_requests parameter
98
- func (mrb * ExtendedRequestBuilder ) BuildRequest (t ibclient.RequestType , obj ibclient.IBObject , ref string , queryParams ibclient.QueryParams ) (req * http.Request , err error ) {
103
+ func (mrb * ExtendedRequestBuilder ) BuildRequest (t ibclient.RequestType , obj ibclient.IBObject , ref string , queryParams * ibclient.QueryParams ) (req * http.Request , err error ) {
99
104
req , err = mrb .WapiRequestBuilder .BuildRequest (t , obj , ref , queryParams )
100
105
if req .Method == "GET" {
101
106
query := req .URL .Query ()
@@ -147,7 +152,7 @@ func NewInfobloxProvider(infobloxConfig InfobloxConfig) (*InfobloxProvider, erro
147
152
return nil , err
148
153
}
149
154
150
- provider := & InfobloxProvider {
155
+ providerCfg := & InfobloxProvider {
151
156
client : client ,
152
157
domainFilter : infobloxConfig .DomainFilter ,
153
158
zoneIDFilter : infobloxConfig .ZoneIDFilter ,
@@ -158,7 +163,7 @@ func NewInfobloxProvider(infobloxConfig InfobloxConfig) (*InfobloxProvider, erro
158
163
cacheDuration : infobloxConfig .CacheDuration ,
159
164
}
160
165
161
- return provider , nil
166
+ return providerCfg , nil
162
167
}
163
168
164
169
// Records gets the current records.
@@ -171,14 +176,11 @@ func (p *InfobloxProvider) Records(ctx context.Context) (endpoints []*endpoint.E
171
176
for _ , zone := range zones {
172
177
logrus .Debugf ("fetch records from zone '%s'" , zone .Fqdn )
173
178
var resA []ibclient.RecordA
174
- objA := ibclient .NewRecordA (
175
- ibclient.RecordA {
176
- Zone : zone .Fqdn ,
177
- View : p .view ,
178
- },
179
- )
180
- err = p .client .GetObject (objA , "" , & resA )
181
- if err != nil {
179
+ objA := ibclient .NewEmptyRecordA ()
180
+ objA .View = p .view
181
+ objA .Zone = zone .Fqdn
182
+ err = p .client .GetObject (objA , "" , ibclient .NewQueryParams (false , nil ), & resA )
183
+ if err != nil && ! isNotFoundError (err ) {
182
184
return nil , fmt .Errorf ("could not fetch A records from zone '%s': %s" , zone .Fqdn , err )
183
185
}
184
186
for _ , res := range resA {
@@ -207,14 +209,11 @@ func (p *InfobloxProvider) Records(ctx context.Context) (endpoints []*endpoint.E
207
209
208
210
// Include Host records since they should be treated synonymously with A records
209
211
var resH []ibclient.HostRecord
210
- objH := ibclient .NewHostRecord (
211
- ibclient.HostRecord {
212
- Zone : zone .Fqdn ,
213
- View : p .view ,
214
- },
215
- )
216
- err = p .client .GetObject (objH , "" , & resH )
217
- if err != nil {
212
+ objH := ibclient .NewEmptyHostRecord ()
213
+ objH .View = p .view
214
+ objH .Zone = zone .Fqdn
215
+ err = p .client .GetObject (objH , "" , ibclient .NewQueryParams (false , nil ), & resH )
216
+ if err != nil && ! isNotFoundError (err ) {
218
217
return nil , fmt .Errorf ("could not fetch host records from zone '%s': %s" , zone .Fqdn , err )
219
218
}
220
219
for _ , res := range resH {
@@ -232,14 +231,11 @@ func (p *InfobloxProvider) Records(ctx context.Context) (endpoints []*endpoint.E
232
231
}
233
232
234
233
var resC []ibclient.RecordCNAME
235
- objC := ibclient .NewRecordCNAME (
236
- ibclient.RecordCNAME {
237
- Zone : zone .Fqdn ,
238
- View : p .view ,
239
- },
240
- )
241
- err = p .client .GetObject (objC , "" , & resC )
242
- if err != nil {
234
+ objC := ibclient .NewEmptyRecordCNAME ()
235
+ objC .View = p .view
236
+ objC .Zone = zone .Fqdn
237
+ err = p .client .GetObject (objC , "" , ibclient .NewQueryParams (false , nil ), & resC )
238
+ if err != nil && ! isNotFoundError (err ) {
243
239
return nil , fmt .Errorf ("could not fetch CNAME records from zone '%s': %s" , zone .Fqdn , err )
244
240
}
245
241
for _ , res := range resC {
@@ -254,14 +250,11 @@ func (p *InfobloxProvider) Records(ctx context.Context) (endpoints []*endpoint.E
254
250
arpaZone , err := transform .ReverseDomainName (zone .Fqdn )
255
251
if err == nil {
256
252
var resP []ibclient.RecordPTR
257
- objP := ibclient .NewRecordPTR (
258
- ibclient.RecordPTR {
259
- Zone : arpaZone ,
260
- View : p .view ,
261
- },
262
- )
263
- err = p .client .GetObject (objP , "" , & resP )
264
- if err != nil {
253
+ objP := ibclient .NewEmptyRecordPTR ()
254
+ objP .Zone = arpaZone
255
+ objP .View = p .view
256
+ err = p .client .GetObject (objP , "" , ibclient .NewQueryParams (false , nil ), & resP )
257
+ if err != nil && ! isNotFoundError (err ) {
265
258
return nil , fmt .Errorf ("could not fetch PTR records from zone '%s': %s" , zone .Fqdn , err )
266
259
}
267
260
for _ , res := range resP {
@@ -277,8 +270,8 @@ func (p *InfobloxProvider) Records(ctx context.Context) (endpoints []*endpoint.E
277
270
View : p .view ,
278
271
},
279
272
)
280
- err = p .client .GetObject (objT , "" , & resT )
281
- if err != nil {
273
+ err = p .client .GetObject (objT , "" , ibclient . NewQueryParams ( false , nil ), & resT )
274
+ if err != nil && ! isNotFoundError ( err ) {
282
275
return nil , fmt .Errorf ("could not fetch TXT records from zone '%s': %s" , zone .Fqdn , err )
283
276
}
284
277
for _ , res := range resT {
@@ -377,9 +370,8 @@ func (p *InfobloxProvider) zones() ([]ibclient.ZoneAuth, error) {
377
370
View : p .view ,
378
371
},
379
372
)
380
- err := p .client .GetObject (obj , "" , & res )
381
-
382
- if err != nil {
373
+ err := p .client .GetObject (obj , "" , ibclient .NewQueryParams (false , nil ), & res )
374
+ if err != nil && ! isNotFoundError (err ) {
383
375
return nil , err
384
376
}
385
377
@@ -466,12 +458,12 @@ func (p *InfobloxProvider) findReverseZone(zones []ibclient.ZoneAuth, name strin
466
458
maxMask := 0
467
459
468
460
for i , zone := range zones {
469
- _ , net , err := net .ParseCIDR (zone .Fqdn )
461
+ _ , rZoneNet , err := net .ParseCIDR (zone .Fqdn )
470
462
if err != nil {
471
463
logrus .WithError (err ).Debugf ("fqdn %s is no cidr" , zone .Fqdn )
472
464
} else {
473
- if net .Contains (ip ) {
474
- _ , mask := net .Mask .Size ()
465
+ if rZoneNet .Contains (ip ) {
466
+ _ , mask := rZoneNet .Mask .Size ()
475
467
networks [mask ] = & zones [i ]
476
468
if mask > maxMask {
477
469
maxMask = mask
@@ -486,16 +478,13 @@ func (p *InfobloxProvider) recordSet(ep *endpoint.Endpoint, getObject bool, targ
486
478
switch ep .RecordType {
487
479
case endpoint .RecordTypeA :
488
480
var res []ibclient.RecordA
489
- obj := ibclient .NewRecordA (
490
- ibclient.RecordA {
491
- Name : ep .DNSName ,
492
- Ipv4Addr : ep .Targets [targetIndex ],
493
- View : p .view ,
494
- },
495
- )
481
+ obj := ibclient .NewEmptyRecordA ()
482
+ obj .Name = ep .DNSName
483
+ obj .Ipv4Addr = ep .Targets [targetIndex ]
484
+ obj .View = p .view
496
485
if getObject {
497
- err = p .client .GetObject (obj , "" , & res )
498
- if err != nil {
486
+ err = p .client .GetObject (obj , "" , ibclient . NewQueryParams ( false , nil ), & res )
487
+ if err != nil && ! isNotFoundError ( err ) {
499
488
return
500
489
}
501
490
}
@@ -505,16 +494,13 @@ func (p *InfobloxProvider) recordSet(ep *endpoint.Endpoint, getObject bool, targ
505
494
}
506
495
case endpoint .RecordTypePTR :
507
496
var res []ibclient.RecordPTR
508
- obj := ibclient .NewRecordPTR (
509
- ibclient.RecordPTR {
510
- PtrdName : ep .DNSName ,
511
- Ipv4Addr : ep .Targets [targetIndex ],
512
- View : p .view ,
513
- },
514
- )
497
+ obj := ibclient .NewEmptyRecordPTR ()
498
+ obj .PtrdName = ep .DNSName
499
+ obj .Ipv4Addr = ep .Targets [targetIndex ]
500
+ obj .View = p .view
515
501
if getObject {
516
- err = p .client .GetObject (obj , "" , & res )
517
- if err != nil {
502
+ err = p .client .GetObject (obj , "" , ibclient . NewQueryParams ( false , nil ), & res )
503
+ if err != nil && ! isNotFoundError ( err ) {
518
504
return
519
505
}
520
506
}
@@ -524,16 +510,13 @@ func (p *InfobloxProvider) recordSet(ep *endpoint.Endpoint, getObject bool, targ
524
510
}
525
511
case endpoint .RecordTypeCNAME :
526
512
var res []ibclient.RecordCNAME
527
- obj := ibclient .NewRecordCNAME (
528
- ibclient.RecordCNAME {
529
- Name : ep .DNSName ,
530
- Canonical : ep .Targets [0 ],
531
- View : p .view ,
532
- },
533
- )
513
+ obj := ibclient .NewEmptyRecordCNAME ()
514
+ obj .Name = ep .DNSName
515
+ obj .Canonical = ep .Targets [0 ]
516
+ obj .View = p .view
534
517
if getObject {
535
- err = p .client .GetObject (obj , "" , & res )
536
- if err != nil {
518
+ err = p .client .GetObject (obj , "" , ibclient . NewQueryParams ( false , nil ), & res )
519
+ if err != nil && ! isNotFoundError ( err ) {
537
520
return
538
521
}
539
522
}
@@ -556,8 +539,8 @@ func (p *InfobloxProvider) recordSet(ep *endpoint.Endpoint, getObject bool, targ
556
539
},
557
540
)
558
541
if getObject {
559
- err = p .client .GetObject (obj , "" , & res )
560
- if err != nil {
542
+ err = p .client .GetObject (obj , "" , ibclient . NewQueryParams ( false , nil ), & res )
543
+ if err != nil && ! isNotFoundError ( err ) {
561
544
return
562
545
}
563
546
}
0 commit comments