Implement libdns ZoneLister interface for provider

This commit is contained in:
Alexandre Oliveira 2023-03-31 16:15:31 +02:00
parent 44dad6df97
commit e079f301dd
3 changed files with 52 additions and 0 deletions

View file

@ -121,3 +121,35 @@ func (p *Provider) updateDNSRecord(ctx context.Context, domain string, record li
return record, nil
}
func (p *Provider) getDNSZones(ctx context.Context) ([]libdns.Zone, error) {
p.client.mutex.Lock()
defer p.client.mutex.Unlock()
p.getClient()
listOptions := &govultr.ListOptions{}
var zones []libdns.Zone
for {
dns_zones, meta, _, err := p.client.vultr.Domain.List(ctx, listOptions)
if err != nil {
return zones, err
}
for _, entry := range dns_zones {
zone := libdns.Zone{
Name: entry.Domain,
}
zones = append(zones, zone)
}
if meta.Links.Next == "" {
break
}
listOptions.Cursor = meta.Links.Next
}
return zones, nil
}