1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

DNSimple: handle pagination appropriately. (#242)

* dnsimple paging

* remove unrelated change
This commit is contained in:
Craig Peterson
2017-10-18 13:53:44 -04:00
committed by GitHub
parent 63498c3ff3
commit 2c5f4c88ea
3 changed files with 18 additions and 7 deletions

View File

@ -308,7 +308,7 @@ func makeTests(t *testing.T) []*TestCase {
tc("Empty"),
tc("NS for subdomain", ns("xyz", "ns2.foo.com.")),
tc("Dual NS for subdomain", ns("xyz", "ns2.foo.com."), ns("xyz", "ns1.foo.com.")),
tc("Record pointing to @", ns("foo", "**current-domain**")),
tc("NS Record pointing to @", ns("foo", "**current-domain**")),
//IDNAs
tc("Empty"),

View File

@ -20,7 +20,7 @@
"COMMENT": "16/17: no ns records managable. Not even for subdomains.",
"baseurl": "https://api.sandbox.dnsimple.com",
"domain": "$DNSIMPLE_DOMAIN",
"knownFailures": "17,18",
"knownFailures": "18,19,20",
"token": "$DNSIMPLE_TOKEN"
},
"GANDI": {

View File

@ -47,7 +47,7 @@ func (c *DnsimpleApi) GetNameservers(domainName string) ([]*models.Nameserver, e
func (c *DnsimpleApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
corrections := []*models.Correction{}
dc.Punycode()
records, err := c.getRecords(dc.Name)
if err != nil {
return nil, err
@ -168,12 +168,23 @@ func (c *DnsimpleApi) getRecords(domainName string) ([]dnsimpleapi.ZoneRecord, e
return nil, err
}
recordsResponse, err := client.Zones.ListRecords(accountId, domainName, nil)
opts := &dnsimpleapi.ZoneRecordListOptions{}
recs := []dnsimpleapi.ZoneRecord{}
opts.Page = 1
for {
recordsResponse, err := client.Zones.ListRecords(accountId, domainName, opts)
if err != nil {
return nil, err
}
recs = append(recs, recordsResponse.Data...)
pg := recordsResponse.Pagination
if pg.CurrentPage == pg.TotalPages {
break
}
opts.Page++
}
return recordsResponse.Data, nil
return recs, nil
}
// Returns the name server names that should be used. If the domain is registered