alidns: add support to handle more than 20 domains (#739)

This commit is contained in:
smartwang 2018-12-20 18:52:34 +08:00 committed by Ludovic Fernandez
parent 15764a17b6
commit cb3c4c7937

View file

@ -136,9 +136,25 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
func (d *DNSProvider) getHostedZone(domain string) (string, string, error) {
request := alidns.CreateDescribeDomainsRequest()
zones, err := d.client.DescribeDomains(request)
if err != nil {
return "", "", fmt.Errorf("API call failed: %v", err)
var domains []alidns.Domain
startPage := 1
for {
request.PageNumber = requests.NewInteger(startPage)
response, err := d.client.DescribeDomains(request)
if err != nil {
return "", "", fmt.Errorf("API call failed: %v", err)
}
domains = append(domains, response.Domains.Domain...)
if response.PageNumber >= response.PageSize {
break
}
startPage++
}
authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
@ -147,7 +163,7 @@ func (d *DNSProvider) getHostedZone(domain string) (string, string, error) {
}
var hostedZone alidns.Domain
for _, zone := range zones.Domains.Domain {
for _, zone := range domains {
if zone.DomainName == dns01.UnFqdn(authZone) {
hostedZone = zone
}