From 6ada79b53652f1b9337388914d01501b0bcbb196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Brunink?= <1129998+jbrunink@users.noreply.github.com> Date: Sat, 27 Jun 2020 02:05:08 +0200 Subject: [PATCH] hetzner: fix record name. (#1199) --- providers/dns/hetzner/hetzner.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/providers/dns/hetzner/hetzner.go b/providers/dns/hetzner/hetzner.go index fedddce6..b0824a90 100644 --- a/providers/dns/hetzner/hetzner.go +++ b/providers/dns/hetzner/hetzner.go @@ -101,7 +101,7 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zone, err := d.getZone(fqdn) + zone, err := getZone(fqdn) if err != nil { return fmt.Errorf("hetzner: failed to find zone: fqdn=%s: %w", fqdn, err) } @@ -113,7 +113,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { record := internal.DNSRecord{ Type: "TXT", - Name: d.extractRecordName(fqdn, domain), + Name: extractRecordName(fqdn, zone), Value: value, TTL: d.config.TTL, ZoneID: zoneID, @@ -130,7 +130,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - zone, err := d.getZone(fqdn) + zone, err := getZone(fqdn) if err != nil { return fmt.Errorf("hetzner: failed to find zone: fqdn=%s: %w", fqdn, err) } @@ -140,7 +140,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("hetzner: %w", err) } - recordName := d.extractRecordName(fqdn, domain) + recordName := extractRecordName(fqdn, zone) record, err := d.client.GetTxtRecord(recordName, value, zoneID) if err != nil { @@ -154,15 +154,15 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return nil } -func (d *DNSProvider) extractRecordName(fqdn, domain string) string { +func extractRecordName(fqdn, zone string) string { name := dns01.UnFqdn(fqdn) - if idx := strings.Index(name, "."+domain); idx != -1 { + if idx := strings.Index(name, "."+zone); idx != -1 { return name[:idx] } return name } -func (d *DNSProvider) getZone(fqdn string) (string, error) { +func getZone(fqdn string) (string, error) { authZone, err := dns01.FindZoneByFqdn(fqdn) if err != nil { return "", err