From 06376d5be677a1d6dc890217b7b5fee735be299c Mon Sep 17 00:00:00 2001 From: Kiswono Prayogo Date: Wed, 28 Feb 2024 17:03:45 +0700 Subject: [PATCH] remove unecessary function from interface --- gcoreprovider/gcore.go | 1 - go.mod | 2 +- go.sum | 4 +-- .../G-Core/gcore-dns-sdk-go/client.go | 32 +++++++++++++++++-- vendor/modules.txt | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/gcoreprovider/gcore.go b/gcoreprovider/gcore.go index 30559dd..821273e 100644 --- a/gcoreprovider/gcore.go +++ b/gcoreprovider/gcore.go @@ -40,7 +40,6 @@ type dnsManager interface { values []gdns.ResourceRecord, ttl int, opts ...gdns.AddZoneOpt) error ZonesWithRecords(ctx context.Context, filters ...func(zone *gdns.ZonesFilter)) ([]gdns.Zone, error) Zones(ctx context.Context, filters ...func(zone *gdns.ZonesFilter)) ([]gdns.Zone, error) - AllZones(ctx context.Context) ([]gdns.Zone, error) DeleteRRSetRecord(ctx context.Context, zone, name, recordType string, contents ...string) error } diff --git a/go.mod b/go.mod index 332299c..268fb59 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/G-Core/external-dns-gcore-webhook go 1.21 require ( - github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20240226132216-e38e3d3b4c10 + github.com/G-Core/gcore-dns-sdk-go v0.2.8-0.20240228095703-bbc269a7d1f8 github.com/go-chi/chi/v5 v5.0.11 github.com/sirupsen/logrus v1.9.3 golang.org/x/sync v0.6.0 diff --git a/go.sum b/go.sum index 35deca3..98a3f97 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20240226132216-e38e3d3b4c10 h1:i6lnGeF/RFrd1LZ2rGXlp/vIvTiYGE7oksPLpEnvKPY= -github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20240226132216-e38e3d3b4c10/go.mod h1:ky5q2+je2gyVpM2eGdlXbv/KRmD9nimtNQkjzDbXVys= +github.com/G-Core/gcore-dns-sdk-go v0.2.8-0.20240228095703-bbc269a7d1f8 h1:Ve8drjq/siJbe5dOOKhLHK2m8Jl2de1A3a3GHiivhfQ= +github.com/G-Core/gcore-dns-sdk-go v0.2.8-0.20240228095703-bbc269a7d1f8/go.mod h1:ky5q2+je2gyVpM2eGdlXbv/KRmD9nimtNQkjzDbXVys= github.com/aws/aws-sdk-go v1.44.311 h1:60i8hyVMOXqabKJQPCq4qKRBQ6hRafI/WOcDxGM+J7Q= github.com/aws/aws-sdk-go v1.44.311/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/vendor/github.com/G-Core/gcore-dns-sdk-go/client.go b/vendor/github.com/G-Core/gcore-dns-sdk-go/client.go index c211211..3884e88 100644 --- a/vendor/github.com/G-Core/gcore-dns-sdk-go/client.go +++ b/vendor/github.com/G-Core/gcore-dns-sdk-go/client.go @@ -268,7 +268,7 @@ func (c *Client) ZonesWithParam(ctx context.Context, param ZonesParam) (res List } // AllZones get all zones per 1k -func (c *Client) AllZones(ctx context.Context) ([]Zone, error) { +func (c *Client) AllZones(ctx context.Context, nameFilters []string) ([]Zone, error) { offset := 0 const limit = 1000 var zones []Zone @@ -276,6 +276,7 @@ func (c *Client) AllZones(ctx context.Context) ([]Zone, error) { param := ZonesParam{ Offset: uint64(offset), Limit: uint64(limit), + Name: nameFilters, } zoneRes, err := c.ZonesWithParam(ctx, param) if err != nil { @@ -294,7 +295,7 @@ func (c *Client) AllZones(ctx context.Context) ([]Zone, error) { return zones, nil } -// ZonesWithRecords gets all zones with records information. +// ZonesWithRecords gets first 100 zones with records information. func (c *Client) ZonesWithRecords(ctx context.Context, filters ...func(zone *ZonesFilter)) ([]Zone, error) { zones, err := c.Zones(ctx, filters...) if err != nil { @@ -321,6 +322,33 @@ func (c *Client) ZonesWithRecords(ctx context.Context, filters ...func(zone *Zon return zones, nil } +// AllZonesWithRecords gets all zones with records information. +func (c *Client) AllZonesWithRecords(ctx context.Context, nameFilters []string) ([]Zone, error) { + zones, err := c.AllZones(ctx, nameFilters) + if err != nil { + return nil, fmt.Errorf("all zones: %w", err) + } + gr, _ := errgroup.WithContext(ctx) + for i, z := range zones { + z := z + i := i + gr.Go(func() error { + zone, errGet := c.Zone(ctx, z.Name) + if errGet != nil { + return fmt.Errorf("%s: %w", z.Name, errGet) + } + zones[i] = zone + return nil + }) + } + err = gr.Wait() + if err != nil { + return nil, fmt.Errorf("zone info: %w", err) + } + + return zones, nil +} + // DeleteZone gets zone information. // https://apidocs.gcore.com/dns#tag/zones/operation/DeleteZone func (c *Client) DeleteZone(ctx context.Context, name string) error { diff --git a/vendor/modules.txt b/vendor/modules.txt index f482e58..c332109 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20240226132216-e38e3d3b4c10 +# github.com/G-Core/gcore-dns-sdk-go v0.2.8-0.20240228095703-bbc269a7d1f8 ## explicit; go 1.18 github.com/G-Core/gcore-dns-sdk-go # github.com/aws/aws-sdk-go v1.44.311