@@ -101,31 +101,20 @@ func ToHostResponseMap(res []ibclient.HostRecord) *ResponseMap {
101101 return rm
102102}
103103
104- // TODO: ToPTRResponseMap
105- //if p.createPTR {
106- // // infoblox doesn't accept reverse zone's fqdn, and instead expects .in-addr.arpa zone
107- // // so convert our zone fqdn (if it is a correct cidr block) into in-addr.arpa address and pass that into infoblox
108- // // example: 10.196.38.0/24 becomes 38.196.10.in-addr.arpa
109- // arpaZone, err := transform.ReverseDomainName(zone.Fqdn)
110- // if err == nil {
111- // var resP []ibclient.RecordPTR
112- // objP := ibclient.NewEmptyRecordPTR()
113- // objP.Zone = arpaZone
114- // objP.View = p.view
115- // err = p.client.GetObject(objP, "", searchParams, &resP)
116- // if err != nil && !isNotFoundError(err) {
117- // return nil, fmt.Errorf("could not fetch PTR records from zone '%s': %w", zone.Fqdn, err)
118- // }
119- // for _, res := range resP {
120- // endpoints = append(endpoints, endpoint.NewEndpointWithTTL(res.PtrdName,
121- // endpoint.RecordTypePTR,
122- // endpoint.TTL(int(res.Ttl)),
123- // res.Ipv4Addr,
124- // ),
125- // )
126- // }
127- // }
128- //}
104+ func ToPTRResponseMap (res []ibclient.RecordPTR ) * ResponseMap {
105+ rm := & ResponseMap {
106+ Map : make (map [string ]ResponseDetails ),
107+ RecordType : ibclient .PtrRecord ,
108+ }
109+ for _ , record := range res {
110+ if _ , ok := rm .Map [AsString (record .PtrdName )]; ! ok {
111+ rm .Map [AsString (record .PtrdName )] = ResponseDetails {{Target : AsString (record .Ipv4Addr ), TTL : AsInt64 (record .Ttl )}}
112+ continue
113+ }
114+ rm .Map [AsString (record .PtrdName )] = append (rm .Map [AsString (record .PtrdName )], ResponseDetail {Target : AsString (record .Ipv4Addr ), TTL : AsInt64 (record .Ttl )})
115+ }
116+ return rm
117+ }
129118
130119func (rd ResponseDetails ) ToEndpointDetail () (targets []string , ttl endpoint.TTL ) {
131120 for _ , v := range rd {
@@ -136,10 +125,6 @@ func (rd ResponseDetails) ToEndpointDetail() (targets []string, ttl endpoint.TTL
136125}
137126
138127func (rm * ResponseMap ) ToEndpoints () []* endpoint.Endpoint {
139- // TODO: PTR provider specific label records
140- // if p.createPTR {
141- // newEndpoint.WithProviderSpecific(providerSpecificInfobloxPtrRecord, "true")
142- // }
143128 var endpoints []* endpoint.Endpoint
144129 for k , v := range rm .Map {
145130 targets , ttl := v .ToEndpointDetail ()
@@ -149,34 +134,3 @@ func (rm *ResponseMap) ToEndpoints() []*endpoint.Endpoint {
149134 }
150135 return endpoints
151136}
152-
153- // TODO: update A records that have PTR record created for them already
154- //if p.createPTR {
155- // // save all ptr records into map for a quick look up
156- // ptrRecordsMap := make(map[string]bool)
157- // for _, ptrRecord := range endpoints {
158- // if ptrRecord.RecordType != endpoint.RecordTypePTR {
159- // continue
160- // }
161- // ptrRecordsMap[ptrRecord.DNSName] = true
162- // }
163- //
164- // for i := range endpoints {
165- // if endpoints[i].RecordType != endpoint.RecordTypeA {
166- // continue
167- // }
168- // // if PTR record already exists for A record, then mark it as such
169- // if ptrRecordsMap[endpoints[i].DNSName] {
170- // found := false
171- // for j := range endpoints[i].ProviderSpecific {
172- // if endpoints[i].ProviderSpecific[j].Name == providerSpecificInfobloxPtrRecord {
173- // endpoints[i].ProviderSpecific[j].Value = "true"
174- // found = true
175- // }
176- // }
177- // if !found {
178- // endpoints[i].WithProviderSpecific(providerSpecificInfobloxPtrRecord, "true")
179- // }
180- // }
181- // }
182- //}
0 commit comments