@@ -23,7 +23,11 @@ func (d *StackitDNSProvider) Records(ctx context.Context) ([]*endpoint.Endpoint,
2323 go d .fetchRecordsWorker (ctx , zoneIdsChannel , endpointsErrorChannel )
2424 }
2525
26- for _ , zone := range zones {
26+ for i := range zones {
27+ zone := & zones [i ]
28+ if zone .Id == nil {
29+ continue
30+ }
2731 zoneIdsChannel <- * zone .Id
2832 }
2933
@@ -84,21 +88,39 @@ func (d *StackitDNSProvider) collectEndPoints(
8488 rrSets []stackitdnsclient.RecordSet ,
8589) []* endpoint.Endpoint {
8690 var endpoints []* endpoint.Endpoint
87- for _ , r := range rrSets {
88- recordType := string (* r .Type )
89- if provider .SupportedRecordType (recordType ) {
90- for _ , _r := range * r .Records {
91- endpoints = append (
92- endpoints ,
93- endpoint .NewEndpointWithTTL (
94- * r .Name ,
95- recordType ,
96- endpoint .TTL (* r .Ttl ),
97- * _r .Content ,
98- ),
99- )
100- }
91+
92+ for i := range rrSets {
93+ r := & rrSets [i ]
94+
95+ name , recordType , ttl , records , ok := recordSetCoreFields (r )
96+ if ! ok || ! provider .SupportedRecordType (recordType ) {
97+ continue
98+ }
99+
100+ endpoints = append (endpoints , endpointsFromRecords (name , recordType , ttl , records )... )
101+ }
102+
103+ return endpoints
104+ }
105+
106+ func recordSetCoreFields (r * stackitdnsclient.RecordSet ) (name string , recordType string , ttl endpoint.TTL , records []stackitdnsclient.Record , ok bool ) {
107+ if r == nil || r .Type == nil || r .Name == nil || r .Ttl == nil || r .Records == nil {
108+ return "" , "" , 0 , nil , false
109+ }
110+
111+ return * r .Name , string (* r .Type ), endpoint .TTL (* r .Ttl ), * r .Records , true
112+ }
113+
114+ func endpointsFromRecords (name , recordType string , ttl endpoint.TTL , records []stackitdnsclient.Record ) []* endpoint.Endpoint {
115+ endpoints := make ([]* endpoint.Endpoint , 0 , len (records ))
116+
117+ for i := range records {
118+ rec := & records [i ]
119+ if rec .Content == nil {
120+ continue
101121 }
122+
123+ endpoints = append (endpoints , endpoint .NewEndpointWithTTL (name , recordType , ttl , * rec .Content ))
102124 }
103125
104126 return endpoints
0 commit comments