@@ -241,6 +241,17 @@ func (p *Provider) Records(_ context.Context) (endpoints []*endpoint.Endpoint, e
241241 endpointsTXT := ToTXTResponseMap (resT ).ToEndpoints ()
242242 endpoints = append (endpoints , endpointsTXT ... )
243243
244+ var resNS []ibclient.RecordNS
245+ objNS := ibclient .NewEmptyRecordNS ()
246+ objNS .View = p .config .View
247+ objNS .Zone = zone .Fqdn
248+ err = PagingGetObject (p .client , objNS , "" , searchParams , & resNS )
249+ if err != nil && ! isNotFoundError (err ) {
250+ return nil , fmt .Errorf ("could not fetch NS records from zone '%s': %w" , zone .Fqdn , err )
251+ }
252+ endpointsNS := ToNSResponseMap (resNS ).ToEndpoints ()
253+ endpoints = append (endpoints , endpointsNS ... )
254+
244255 if p .config .CreatePTR {
245256 arpaZone , err := rfc2317 .CidrToInAddr (zone .Fqdn )
246257 if err == nil {
@@ -451,6 +462,13 @@ func getRefID(record *infobloxRecordSet) (string, log.Fields, error) {
451462 return r .Ref , l , nil
452463 }
453464 return "" , l , nil
465+ case "RecordNS" :
466+ l ["record" ] = record .obj .(* ibclient.RecordNS ).Name
467+ l ["target" ] = AsString (record .obj .(* ibclient.RecordNS ).Nameserver )
468+ for _ , r := range * record .res .(* []ibclient.RecordNS ) {
469+ return r .Ref , l , nil
470+ }
471+ return "" , l , nil
454472 }
455473 return "" , l , fmt .Errorf ("unknown type '%s'" , t )
456474}
@@ -758,6 +776,26 @@ func (p *Provider) recordSet(ep *endpoint.Endpoint, getObject bool) (recordSet i
758776 obj : obj ,
759777 res : & res ,
760778 }
779+ case endpoint .RecordTypeNS :
780+ var res []ibclient.RecordNS
781+ obj := ibclient .NewEmptyRecordNS ()
782+ obj .Name = ep .DNSName
783+ obj .Nameserver = & ep .Targets [0 ]
784+ if getObject {
785+ queryParams := ibclient .NewQueryParams (false , map [string ]string {"name" : obj .Name })
786+ err = p .client .GetObject (obj , "" , queryParams , & res )
787+ if err != nil && ! isNotFoundError (err ) {
788+ return
789+ }
790+ } else {
791+ // If getObject is not set (action == create), we need to set the View for Infoblox to find the parent zone
792+ // If View is set for the other actions, Infoblox will complain that the view field is not allowed
793+ obj .View = p .config .View
794+ }
795+ recordSet = infobloxRecordSet {
796+ obj : obj ,
797+ res : & res ,
798+ }
761799 case endpoint .RecordTypeTXT :
762800 var res []ibclient.RecordTXT
763801 // The Infoblox API strips enclosing double quotes from TXT records lacking whitespace.
0 commit comments