aboutsummaryrefslogtreecommitdiff
path: root/plugin/clouddns/gcp.go
diff options
context:
space:
mode:
authorGravatar luanphantiki <49431969+luanphantiki@users.noreply.github.com> 2021-01-12 19:38:18 +0700
committerGravatar GitHub <noreply@github.com> 2021-01-12 13:38:18 +0100
commited891c5c4e494248385510844c05a50826bff6a8 (patch)
tree24d6eb878af02e67cb6fdf90d8615d61ff6539dc /plugin/clouddns/gcp.go
parent0f307cf7284f52307e991526919e0e58895c3a33 (diff)
downloadcoredns-ed891c5c4e494248385510844c05a50826bff6a8.tar.gz
coredns-ed891c5c4e494248385510844c05a50826bff6a8.tar.zst
coredns-ed891c5c4e494248385510844c05a50826bff6a8.zip
fix record missing for zone with many of records (#4328)
* fix record missing for zone with many of records * Update debug log * Update debug mesg * update test_clouddns
Diffstat (limited to 'plugin/clouddns/gcp.go')
-rw-r--r--plugin/clouddns/gcp.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugin/clouddns/gcp.go b/plugin/clouddns/gcp.go
index 6d9d85d43..0f5126c87 100644
--- a/plugin/clouddns/gcp.go
+++ b/plugin/clouddns/gcp.go
@@ -1,10 +1,14 @@
package clouddns
-import gcp "google.golang.org/api/dns/v1"
+import (
+ "context"
+
+ gcp "google.golang.org/api/dns/v1"
+)
type gcpDNS interface {
zoneExists(projectName, hostedZoneName string) error
- listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error)
+ listRRSets(ctx context.Context, projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error)
}
type gcpClient struct {
@@ -23,10 +27,16 @@ func (c gcpClient) zoneExists(projectName, hostedZoneName string) error {
// listRRSets is a wrapper method around `gcp.Service.ResourceRecordSets.List`
// it fetches and returns the record sets for a hosted zone.
-func (c gcpClient) listRRSets(projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
- rr, err := c.ResourceRecordSets.List(projectName, hostedZoneName).Do()
- if err != nil {
+func (c gcpClient) listRRSets(ctx context.Context, projectName, hostedZoneName string) (*gcp.ResourceRecordSetsListResponse, error) {
+ req := c.ResourceRecordSets.List(projectName, hostedZoneName)
+ var rs []*gcp.ResourceRecordSet
+ if err := req.Pages(ctx, func(page *gcp.ResourceRecordSetsListResponse) error {
+ for _, rr := range page.Rrsets {
+ rs = append(rs, rr)
+ }
+ return nil
+ }); err != nil {
return nil, err
}
- return rr, nil
+ return &gcp.ResourceRecordSetsListResponse{Rrsets: rs}, nil
}