From 2c5f4c88ead3a49f40b07ce9b5e8c57d6eaa98b6 Mon Sep 17 00:00:00 2001 From: Craig Peterson Date: Wed, 18 Oct 2017 13:53:44 -0400 Subject: [PATCH] DNSimple: handle pagination appropriately. (#242) * dnsimple paging * remove unrelated change --- integrationTest/integration_test.go | 2 +- integrationTest/providers.json | 2 +- providers/dnsimple/dnsimpleProvider.go | 21 ++++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index e59829d2a..5ef421fc1 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -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"), diff --git a/integrationTest/providers.json b/integrationTest/providers.json index 9acac3f9c..af0a871b4 100644 --- a/integrationTest/providers.json +++ b/integrationTest/providers.json @@ -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": { diff --git a/providers/dnsimple/dnsimpleProvider.go b/providers/dnsimple/dnsimpleProvider.go index 9d302bd4a..84599a1f1 100644 --- a/providers/dnsimple/dnsimpleProvider.go +++ b/providers/dnsimple/dnsimpleProvider.go @@ -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) - if err != nil { - return nil, err + 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