@@ -12,7 +12,7 @@ import (
1212
1313 "github.com/go-acme/lego/v4/challenge/dns01"
1414 "github.com/go-acme/lego/v4/platform/config/env"
15- "github.com/vultr/govultr/v2 "
15+ "github.com/vultr/govultr/v3 "
1616 "golang.org/x/oauth2"
1717)
1818
@@ -110,9 +110,10 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
110110 TTL : d .config .TTL ,
111111 Priority : func (v int ) * int { return & v }(0 ),
112112 }
113- _ , err = d .client .DomainRecord .Create (ctx , zoneDomain , & req )
113+
114+ _ , resp , err := d .client .DomainRecord .Create (ctx , zoneDomain , & req )
114115 if err != nil {
115- return fmt .Errorf ("vultr: API call failed: %w" , err )
116+ return fmt .Errorf ("vultr: %w" , extendError ( resp , err ) )
116117 }
117118
118119 return nil
@@ -157,9 +158,9 @@ func (d *DNSProvider) getHostedZone(ctx context.Context, domain string) (string,
157158 var hostedDomain govultr.Domain
158159
159160 for {
160- domains , meta , err := d .client .Domain .List (ctx , listOptions )
161+ domains , meta , resp , err := d .client .Domain .List (ctx , listOptions )
161162 if err != nil {
162- return "" , fmt . Errorf ( "API call failed: %w" , err )
163+ return "" , extendError ( resp , err )
163164 }
164165
165166 for _ , dom := range domains {
@@ -201,9 +202,9 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, domain, fqdn string) (
201202
202203 var records []govultr.DomainRecord
203204 for {
204- result , meta , err := d .client .DomainRecord .List (ctx , zoneDomain , listOptions )
205+ result , meta , resp , err := d .client .DomainRecord .List (ctx , zoneDomain , listOptions )
205206 if err != nil {
206- return "" , records , fmt . Errorf ( "API call has failed: %w" , err )
207+ return "" , records , extendError ( resp , err )
207208 }
208209
209210 for _ , record := range result {
@@ -234,3 +235,12 @@ func OAuthStaticAccessToken(client *http.Client, accessToken string) *http.Clien
234235
235236 return client
236237}
238+
239+ func extendError (resp * http.Response , err error ) error {
240+ msg := "API call failed"
241+ if resp != nil {
242+ msg += fmt .Sprintf (" (%d)" , resp .StatusCode )
243+ }
244+
245+ return fmt .Errorf ("%s: %w" , msg , err )
246+ }
0 commit comments