@@ -46,6 +46,7 @@ const (
4646
4747// Config is used to configure the creation of the DNSProvider.
4848type Config struct {
49+ ZoneName string
4950 PropagationTimeout time.Duration
5051 PollingInterval time.Duration
5152 TTL int
@@ -55,6 +56,7 @@ type Config struct {
5556// NewDefaultConfig returns a default configuration for the DNSProvider.
5657func NewDefaultConfig () * Config {
5758 return & Config {
59+ ZoneName : env .GetOrFile (EnvZoneName ),
5860 TTL : env .GetOrDefaultInt (EnvTTL , 10 ),
5961 PropagationTimeout : env .GetOrDefaultSecond (EnvPropagationTimeout , 10 * time .Minute ),
6062 PollingInterval : env .GetOrDefaultSecond (EnvPollingInterval , 10 * time .Second ),
@@ -129,7 +131,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
129131func (d * DNSProvider ) Present (domain , token , keyAuth string ) error {
130132 info := dns01 .GetChallengeInfo (domain , keyAuth )
131133
132- zone , err := getAuthZone (info .EffectiveFQDN )
134+ zone , err := d . getZoneName (info .EffectiveFQDN )
133135 if err != nil {
134136 return fmt .Errorf ("designate: %w" , err )
135137 }
@@ -169,7 +171,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
169171func (d * DNSProvider ) CleanUp (domain , token , keyAuth string ) error {
170172 info := dns01 .GetChallengeInfo (domain , keyAuth )
171173
172- zone , err := getAuthZone (info .EffectiveFQDN )
174+ zone , err := d . getZoneName (info .EffectiveFQDN )
173175 if err != nil {
174176 return fmt .Errorf ("designate: %w" , err )
175177 }
@@ -276,15 +278,18 @@ func (d *DNSProvider) getRecord(zoneID, wanted string) (*recordsets.RecordSet, e
276278 return nil , nil
277279}
278280
279- func getAuthZone (fqdn string ) (string , error ) {
280- authZone := env .GetOrFile (EnvZoneName )
281- if authZone != "" {
282- return authZone , nil
281+ func (d * DNSProvider ) getZoneName (fqdn string ) (string , error ) {
282+ if d .config .ZoneName != "" {
283+ return d .config .ZoneName , nil
283284 }
284285
285286 authZone , err := dns01 .FindZoneByFqdn (fqdn )
286287 if err != nil {
287- return "" , fmt .Errorf ("could not find zone: %w" , err )
288+ return "" , fmt .Errorf ("could not find zone for %s: %w" , fqdn , err )
289+ }
290+
291+ if authZone == "" {
292+ return "" , errors .New ("empty zone name" )
288293 }
289294
290295 return authZone , nil
0 commit comments