From ce6006cce7b6877bc56dfb6c9df969e47e7cbb86 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Sat, 3 Apr 2021 16:31:25 +0200 Subject: [PATCH] GANDI_V5 & OVH: Implement ZoneLister (#1117) * GANDI_V5: implement ZoneLister * OVH: implement ZoneLister --- providers/gandiv5/gandi_v5Provider.go | 16 ++++++++++++++++ providers/ovh/ovhProvider.go | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/providers/gandiv5/gandi_v5Provider.go b/providers/gandiv5/gandi_v5Provider.go index c3e3f9fcc..a34a71e5e 100644 --- a/providers/gandiv5/gandi_v5Provider.go +++ b/providers/gandiv5/gandi_v5Provider.go @@ -98,6 +98,22 @@ func newHelper(m map[string]string, metadata json.RawMessage) (*gandiv5Provider, // Section 3: Domain Service Provider (DSP) related functions +// ListZones lists the zones on this account. +func (client *gandiv5Provider) ListZones() ([]string, error) { + g := gandi.NewLiveDNSClient(client.apikey, gandi.Config{SharingID: client.sharingid, Debug: client.debug}) + + listResp, err := g.ListDomains() + if err != nil { + return nil, err + } + + zones := make([]string, len(listResp)) + for i, zone := range listResp { + zones[i] = zone.FQDN + } + return zones, nil +} + // NB(tal): To future-proof your code, all new providers should // implement GetDomainCorrections exactly as you see here // (byte-for-byte the same). In 3.0 diff --git a/providers/ovh/ovhProvider.go b/providers/ovh/ovhProvider.go index 0cd0ca85f..0427ad1d4 100644 --- a/providers/ovh/ovhProvider.go +++ b/providers/ovh/ovhProvider.go @@ -85,6 +85,14 @@ func (e errNoExist) Error() string { return fmt.Sprintf("Domain %s not found in your ovh account", e.domain) } +// ListZones lists the zones on this account. +func (c *ovhProvider) ListZones() (zones []string, err error) { + for zone := range c.zones { + zones = append(zones, zone) + } + return +} + // GetZoneRecords gets the records of a zone and returns them in RecordConfig format. func (c *ovhProvider) GetZoneRecords(domain string) (models.Records, error) { if !c.zones[domain] {