diff --git a/digitalocean/certificate/datasource_certificate.go b/digitalocean/certificate/datasource_certificate.go index 064989b12..163e323e1 100644 --- a/digitalocean/certificate/datasource_certificate.go +++ b/digitalocean/certificate/datasource_certificate.go @@ -94,35 +94,21 @@ func dataSourceDigitalOceanCertificateRead(ctx context.Context, d *schema.Resour func FindCertificateByName(client *godo.Client, name string) (*godo.Certificate, error) { opts := &godo.ListOptions{ - Page: 1, - PerPage: 200, + Name: name, } - for { - certs, resp, err := client.Certificates.List(context.Background(), opts) - if resp != nil && resp.StatusCode == http.StatusNotFound { - return nil, nil - } - if err != nil { - return nil, fmt.Errorf("Error retrieving certificates: %s", err) - } - - for _, cert := range certs { - if cert.Name == name { - return &cert, nil - } - } - - if resp.Links == nil || resp.Links.IsLastPage() { - break - } + certs, resp, err := client.Certificates.List(context.Background(), opts) + if resp != nil && resp.StatusCode == http.StatusNotFound { + return nil, nil + } + if err != nil { + return nil, fmt.Errorf("Error retrieving certificates: %s", err) + } - page, err := resp.Links.CurrentPage() - if err != nil { - return nil, fmt.Errorf("Error retrieving certificates: %s", err) + for _, cert := range certs { + if cert.Name == name { + return &cert, nil } - - opts.Page = page + 1 } return nil, fmt.Errorf("Certificate %s not found", name) diff --git a/go.mod b/go.mod index 6b20f30aa..2083cb587 100644 --- a/go.mod +++ b/go.mod @@ -72,4 +72,7 @@ replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110 replace github.com/keybase/go-crypto v0.0.0-20190523171820-b785b22cc757 => github.com/keybase/go-crypto v0.0.0-20190416182011-b785b22cc757 +//todo: remove before merge +replace github.com/digitalocean/godo v1.108.0 => /Users/deepaks/Desktop/gocode/godo + go 1.21