mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-02-25 16:13:04 +08:00
DIGITALOCEAN: Enable get-zones "all" feature (implement ListZones()) (#2437)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
parent
354063cc09
commit
fddec1db68
1 changed files with 34 additions and 0 deletions
|
@ -109,6 +109,40 @@ retry:
|
|||
return err
|
||||
}
|
||||
|
||||
// ListZones returns the list of zones (domains) in this account.
|
||||
func (api *digitaloceanProvider) ListZones() ([]string, error) {
|
||||
ctx := context.Background()
|
||||
zones := []string{}
|
||||
opt := &godo.ListOptions{PerPage: perPageSize}
|
||||
retry:
|
||||
for {
|
||||
result, resp, err := api.client.Domains.List(ctx, opt)
|
||||
if err != nil {
|
||||
if pauseAndRetry(resp) {
|
||||
goto retry
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, d := range result {
|
||||
zones = append(zones, d.Name)
|
||||
}
|
||||
|
||||
if resp.Links == nil || resp.Links.IsLastPage() {
|
||||
break
|
||||
}
|
||||
|
||||
page, err := resp.Links.CurrentPage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opt.Page = page + 1
|
||||
}
|
||||
|
||||
return zones, nil
|
||||
}
|
||||
|
||||
// GetNameservers returns the nameservers for domain.
|
||||
func (api *digitaloceanProvider) GetNameservers(domain string) ([]*models.Nameserver, error) {
|
||||
return models.ToNameservers(defaultNameServerNames)
|
||||
|
|
Loading…
Reference in a new issue