Add pagination for listing all DNS records
This commit is contained in:
parent
1c618cb082
commit
a8fa24426b
36
client.go
36
client.go
@ -34,21 +34,31 @@ func (p *Provider) getDNSEntries(ctx context.Context, domain string) ([]libdns.R
|
|||||||
|
|
||||||
p.getClient()
|
p.getClient()
|
||||||
|
|
||||||
var records []libdns.Record
|
listOptions := &govultr.ListOptions{}
|
||||||
dns_entries, _, err := p.client.vultr.DomainRecord.List(ctx, domain, nil)
|
|
||||||
if err != nil {
|
|
||||||
return records, err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, entry := range dns_entries {
|
var records []libdns.Record
|
||||||
record := libdns.Record{
|
for {
|
||||||
Name: entry.Name,
|
dns_entries, meta, err := p.client.vultr.DomainRecord.List(ctx, domain, listOptions)
|
||||||
Value: entry.Data,
|
if err != nil {
|
||||||
Type: entry.Type,
|
return records, err
|
||||||
TTL: time.Duration(entry.TTL) * time.Second,
|
|
||||||
ID: entry.ID,
|
|
||||||
}
|
}
|
||||||
records = append(records, record)
|
|
||||||
|
for _, entry := range dns_entries {
|
||||||
|
record := libdns.Record{
|
||||||
|
Name: entry.Name,
|
||||||
|
Value: entry.Data,
|
||||||
|
Type: entry.Type,
|
||||||
|
TTL: time.Duration(entry.TTL) * time.Second,
|
||||||
|
ID: entry.ID,
|
||||||
|
}
|
||||||
|
records = append(records, record)
|
||||||
|
}
|
||||||
|
|
||||||
|
if meta.Links.Next == "" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
listOptions.Cursor = meta.Links.Next
|
||||||
}
|
}
|
||||||
|
|
||||||
return records, nil
|
return records, nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user