From 292ea2820807ae11db7cca1b672d38c83ad6c86e Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 16 Oct 2018 21:42:54 +0200 Subject: [PATCH] Populate ovh zones cache as early as possible (#412) (#417) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Maint: run generate for missing documentation Apparently current master is missing some generated documentation. * Populate ovh zones cache as early as possible (#412) We are caching the OVH zones in GetNameservers. It turns out it isn’t a good idea, because GetNameServers will not be called if the user selects no name servers for a given domain by using for example: ``` D(‘my domain’, DnsProvider(ovh, 0)) { } ``` The subsequent GetDomainCorrections would automatically fail with an unknown domain error, because the zones cache hasn’t been filled in. To solve the issue, the ovh provider now populates the zones cache during initialisation. --- docs/_includes/matrix.html | 4 +++- providers/ovh/ovhProvider.go | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/_includes/matrix.html b/docs/_includes/matrix.html index 6114c3706..ec47e0085 100644 --- a/docs/_includes/matrix.html +++ b/docs/_includes/matrix.html @@ -443,7 +443,9 @@ - + + + diff --git a/providers/ovh/ovhProvider.go b/providers/ovh/ovhProvider.go index fd7676019..8885c62ee 100644 --- a/providers/ovh/ovhProvider.go +++ b/providers/ovh/ovhProvider.go @@ -39,7 +39,11 @@ func newOVH(m map[string]string, metadata json.RawMessage) (*ovhProvider, error) return nil, err } - return &ovhProvider{client: c}, nil + ovh := &ovhProvider{client: c} + if err := ovh.fetchZones(); err != nil { + return nil, err + } + return ovh, nil } func newDsp(conf map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) { @@ -56,9 +60,6 @@ func init() { } func (c *ovhProvider) GetNameservers(domain string) ([]*models.Nameserver, error) { - if err := c.fetchZones(); err != nil { - return nil, err - } _, ok := c.zones[domain] if !ok { return nil, errors.Errorf("%s not listed in zones for ovh account", domain)