Add pagination for listing all DNS records

This commit is contained in:
Alexandre Oliveira 2020-11-28 13:12:01 +01:00
parent 1c618cb082
commit a8fa24426b

View File

@ -34,8 +34,11 @@ func (p *Provider) getDNSEntries(ctx context.Context, domain string) ([]libdns.R
p.getClient() p.getClient()
listOptions := &govultr.ListOptions{}
var records []libdns.Record var records []libdns.Record
dns_entries, _, err := p.client.vultr.DomainRecord.List(ctx, domain, nil) for {
dns_entries, meta, err := p.client.vultr.DomainRecord.List(ctx, domain, listOptions)
if err != nil { if err != nil {
return records, err return records, err
} }
@ -51,6 +54,13 @@ func (p *Provider) getDNSEntries(ctx context.Context, domain string) ([]libdns.R
records = append(records, record) records = append(records, record)
} }
if meta.Links.Next == "" {
break
}
listOptions.Cursor = meta.Links.Next
}
return records, nil return records, nil
} }