diff --git a/providers/dns/digitalocean/client.go b/providers/dns/digitalocean/client.go index 3be5dda5..48e335ae 100644 --- a/providers/dns/digitalocean/client.go +++ b/providers/dns/digitalocean/client.go @@ -57,10 +57,10 @@ func (d *DNSProvider) removeTxtRecord(domain string, recordID int) error { return nil } -func (d *DNSProvider) addTxtRecord(domain, fqdn, value string) (*txtRecordResponse, error) { - authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) +func (d *DNSProvider) addTxtRecord(fqdn, value string) (*txtRecordResponse, error) { + authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(fqdn)) if err != nil { - return nil, fmt.Errorf("could not determine zone for domain: '%s'. %s", domain, err) + return nil, fmt.Errorf("could not determine zone for domain: '%s'. %s", fqdn, err) } reqData := record{Type: "TXT", Name: fqdn, Data: value, TTL: d.config.TTL} diff --git a/providers/dns/digitalocean/digitalocean.go b/providers/dns/digitalocean/digitalocean.go index fa122ef1..0492a596 100644 --- a/providers/dns/digitalocean/digitalocean.go +++ b/providers/dns/digitalocean/digitalocean.go @@ -88,7 +88,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - respData, err := d.addTxtRecord(domain, fqdn, value) + respData, err := d.addTxtRecord(fqdn, value) if err != nil { return fmt.Errorf("digitalocean: %v", err) } @@ -104,6 +104,11 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, _ := dns01.GetRecord(domain, keyAuth) + authZone, err := dns01.FindZoneByFqdn(fqdn) + if err != nil { + return fmt.Errorf("digitalocean: %v", err) + } + // get the record's unique ID from when we created it d.recordIDsMu.Lock() recordID, ok := d.recordIDs[fqdn] @@ -112,7 +117,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("digitalocean: unknown record ID for '%s'", fqdn) } - err := d.removeTxtRecord(domain, recordID) + err = d.removeTxtRecord(authZone, recordID) if err != nil { return fmt.Errorf("digitalocean: %v", err) }