55 "errors"
66 "fmt"
77 "net/http"
8+ "strings"
89 "time"
910
1011 "github.com/go-acme/lego/v4/challenge"
@@ -13,6 +14,7 @@ import (
1314 "github.com/go-acme/lego/v4/providers/dns/internal/useragent"
1415 client "github.com/sacloud/api-client-go"
1516 "github.com/sacloud/iaas-api-go"
17+ "github.com/sacloud/iaas-api-go/defaults"
1618 "github.com/sacloud/iaas-api-go/helper/api"
1719)
1820
@@ -104,7 +106,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
104106 }
105107
106108 return & DNSProvider {
107- client : iaas .NewDNSOp (api . NewCallerWithOptions (api .MergeOptions (defaultOption , options ))),
109+ client : iaas .NewDNSOp (newCallerWithOptions (api .MergeOptions (defaultOption , options ))),
108110 config : config ,
109111 }, nil
110112}
@@ -138,3 +140,37 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
138140func (d * DNSProvider ) Timeout () (timeout , interval time.Duration ) {
139141 return d .config .PropagationTimeout , d .config .PollingInterval
140142}
143+
144+ // Extracted from https://github.com/sacloud/iaas-api-go/blob/af06b3ccc2c38625d2dc684ad39590d0ae13eed3/helper/api/caller.go#L36-L81
145+ // Trace and fake are removed.
146+ // Related to https://github.com/sacloud/iaas-api-go/issues/376.
147+ func newCallerWithOptions (opts * api.CallerOptions ) iaas.APICaller {
148+ return newCaller (opts )
149+ }
150+
151+ func newCaller (opts * api.CallerOptions ) iaas.APICaller {
152+ if opts .UserAgent == "" {
153+ opts .UserAgent = iaas .DefaultUserAgent
154+ }
155+
156+ caller := iaas .NewClientWithOptions (opts .Options )
157+
158+ defaults .DefaultStatePollingTimeout = 72 * time .Hour
159+
160+ if opts .DefaultZone != "" {
161+ iaas .APIDefaultZone = opts .DefaultZone
162+ }
163+
164+ if len (opts .Zones ) > 0 {
165+ iaas .SakuraCloudZones = opts .Zones
166+ }
167+
168+ if opts .APIRootURL != "" {
169+ if strings .HasSuffix (opts .APIRootURL , "/" ) {
170+ opts .APIRootURL = strings .TrimRight (opts .APIRootURL , "/" )
171+ }
172+ iaas .SakuraCloudAPIRoot = opts .APIRootURL
173+ }
174+
175+ return caller
176+ }
0 commit comments