Populate ovh zones cache as early as possible (#412) (#417)

* 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.
This commit is contained in:
Brice Figureau 2018-10-16 21:42:54 +02:00 committed by Craig Peterson
parent 93a36cbba9
commit 292ea28208
2 changed files with 8 additions and 5 deletions

View file

@ -443,7 +443,9 @@
<td><i class="fa fa-minus dim"></i></td>
<td><i class="fa fa-minus dim"></i></td>
<td><i class="fa fa-minus dim"></i></td>
<td><i class="fa fa-minus dim"></i></td>
<td class="success">
<i class="fa fa-check text-success" aria-hidden="true"></i>
</td>
<td class="success">
<i class="fa fa-check text-success" aria-hidden="true"></i>
</td>

View file

@ -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)