From 028e41285079059692da54d2d9637b440b5c430b Mon Sep 17 00:00:00 2001 From: Bo Shi Date: Thu, 21 Jul 2016 19:05:16 +0000 Subject: [PATCH] Filter Google Cloud DNS List() calls Make a more efficient API call to only fetch the name of interest. --- providers/dns/googlecloud/googlecloud.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/providers/dns/googlecloud/googlecloud.go b/providers/dns/googlecloud/googlecloud.go index f5026056..a9a9903e 100644 --- a/providers/dns/googlecloud/googlecloud.go +++ b/providers/dns/googlecloud/googlecloud.go @@ -121,14 +121,17 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) { // getHostedZone returns the managed-zone func (c *DNSProvider) getHostedZone(domain string) (string, error) { - - zones, err := c.client.ManagedZones.List(c.project).Do() + dnsName := domain + "." + zones, err := c.client.ManagedZones. + List(c.project). + DnsName(dnsName). + Do() if err != nil { return "", fmt.Errorf("GoogleCloud API call failed: %v", err) } for _, z := range zones.ManagedZones { - if strings.HasSuffix(domain+".", z.DnsName) { + if strings.HasSuffix(dnsName, z.DnsName) { return z.Name, nil } }