diff --git a/providers/dns/alidns/alidns.go b/providers/dns/alidns/alidns.go index 06f09da0..b2b31be5 100644 --- a/providers/dns/alidns/alidns.go +++ b/providers/dns/alidns/alidns.go @@ -201,7 +201,7 @@ func (d *DNSProvider) newTxtRecord(zone, fqdn, value string) (*alidns.AddDomainR request.DomainName = zone var err error - request.RR, err = d.extractRecordName(fqdn, zone) + request.RR, err = extractRecordName(fqdn, zone) if err != nil { return nil, err } @@ -229,7 +229,7 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]alidns.Record, erro return records, fmt.Errorf("API call has failed: %w", err) } - recordName, err := d.extractRecordName(fqdn, zoneName) + recordName, err := extractRecordName(fqdn, zoneName) if err != nil { return nil, err } @@ -242,8 +242,8 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]alidns.Record, erro return records, nil } -func (d *DNSProvider) extractRecordName(fqdn, domain string) (string, error) { - asciiDomain, err := idna.ToASCII(domain) +func extractRecordName(fqdn, zone string) (string, error) { + asciiDomain, err := idna.ToASCII(zone) if err != nil { return "", fmt.Errorf("fail to convert punycode: %w", err) } diff --git a/providers/dns/arvancloud/arvancloud.go b/providers/dns/arvancloud/arvancloud.go index c3c6c1cd..6a1b58cc 100644 --- a/providers/dns/arvancloud/arvancloud.go +++ b/providers/dns/arvancloud/arvancloud.go @@ -116,7 +116,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { record := internal.DNSRecord{ Type: "txt", - Name: d.extractRecordName(fqdn, domain), + Name: extractRecordName(fqdn, authZone), Value: internal.TXTRecordValue{Text: value}, TTL: d.config.TTL, UpstreamHTTPS: "default", @@ -177,9 +177,9 @@ func getZone(fqdn string) (string, error) { return dns01.UnFqdn(authZone), 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 diff --git a/providers/dns/dnsimple/dnsimple.go b/providers/dns/dnsimple/dnsimple.go index a78514fc..9681cb94 100644 --- a/providers/dns/dnsimple/dnsimple.go +++ b/providers/dns/dnsimple/dnsimple.go @@ -202,9 +202,9 @@ func newTxtRecord(zoneName, fqdn, value string, ttl int) dnsimple.ZoneRecordAttr } } -func 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 diff --git a/providers/dns/dnspod/dnspod.go b/providers/dns/dnspod/dnspod.go index 21831a3d..adefdfa3 100644 --- a/providers/dns/dnspod/dnspod.go +++ b/providers/dns/dnspod/dnspod.go @@ -157,7 +157,7 @@ func (d *DNSProvider) getHostedZone(domain string) (string, string, error) { } func (d *DNSProvider) newTxtRecord(zone, fqdn, value string, ttl int) *dnspod.Record { - name := d.extractRecordName(fqdn, zone) + name := extractRecordName(fqdn, zone) return &dnspod.Record{ Type: "TXT", @@ -180,7 +180,7 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnspod.Record, erro return records, fmt.Errorf("API call has failed: %w", err) } - recordName := d.extractRecordName(fqdn, zoneName) + recordName := extractRecordName(fqdn, zoneName) for _, record := range result { if record.Name == recordName { @@ -191,9 +191,9 @@ func (d *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnspod.Record, erro return records, 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 diff --git a/providers/dns/godaddy/godaddy.go b/providers/dns/godaddy/godaddy.go index cade7aae..13d1a78c 100644 --- a/providers/dns/godaddy/godaddy.go +++ b/providers/dns/godaddy/godaddy.go @@ -101,12 +101,12 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - domainZone, err := d.getZone(fqdn) + domainZone, err := getZone(fqdn) if err != nil { return fmt.Errorf("godaddy: failed to get zone: %w", err) } - recordName := d.extractRecordName(fqdn, domainZone) + recordName := extractRecordName(fqdn, domainZone) records, err := d.getRecords(domainZone, "TXT", recordName) if err != nil { @@ -140,12 +140,12 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - domainZone, err := d.getZone(fqdn) + domainZone, err := getZone(fqdn) if err != nil { return fmt.Errorf("godaddy: failed to get zone: %w", err) } - recordName := d.extractRecordName(fqdn, domainZone) + recordName := extractRecordName(fqdn, domainZone) records, err := d.getRecords(domainZone, "TXT", recordName) if err != nil { @@ -182,15 +182,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 diff --git a/providers/dns/namedotcom/namedotcom.go b/providers/dns/namedotcom/namedotcom.go index 11b54d5e..7a418ed4 100644 --- a/providers/dns/namedotcom/namedotcom.go +++ b/providers/dns/namedotcom/namedotcom.go @@ -115,7 +115,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { request := &namecom.Record{ DomainName: domain, - Host: d.extractRecordName(fqdn, domainDetails.DomainName), + Host: extractRecordName(fqdn, domainDetails.DomainName), Type: "TXT", TTL: uint32(d.config.TTL), Answer: value, @@ -180,9 +180,9 @@ func (d *DNSProvider) getRecords(domain string) ([]*namecom.Record, error) { return records, 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 diff --git a/providers/dns/ovh/ovh.go b/providers/dns/ovh/ovh.go index 5e0a0e0d..37bc27f9 100644 --- a/providers/dns/ovh/ovh.go +++ b/providers/dns/ovh/ovh.go @@ -132,7 +132,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { } authZone = dns01.UnFqdn(authZone) - subDomain := d.extractRecordName(fqdn, authZone) + subDomain := extractRecordName(fqdn, authZone) reqURL := fmt.Sprintf("/domain/zone/%s/record", authZone) reqData := Record{FieldType: "TXT", SubDomain: subDomain, Target: value, TTL: d.config.TTL} @@ -205,9 +205,9 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { return d.config.PropagationTimeout, d.config.PollingInterval } -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 diff --git a/providers/dns/sakuracloud/client.go b/providers/dns/sakuracloud/client.go index 7d663b26..88976913 100644 --- a/providers/dns/sakuracloud/client.go +++ b/providers/dns/sakuracloud/client.go @@ -21,7 +21,7 @@ func (d *DNSProvider) addTXTRecord(fqdn, domain, value string, ttl int) error { return fmt.Errorf("sakuracloud: %w", err) } - name := d.extractRecordName(fqdn, zone.Name) + name := extractRecordName(fqdn, zone.Name) zone.AddRecord(zone.CreateNewRecord(name, "TXT", value, ttl)) _, err = d.client.Update(zone.ID, zone) @@ -41,7 +41,7 @@ func (d *DNSProvider) cleanupTXTRecord(fqdn, domain string) error { return fmt.Errorf("sakuracloud: %w", err) } - records := d.findTxtRecords(fqdn, zone) + records := findTxtRecords(fqdn, zone) for _, record := range records { var updRecords []sacloud.DNSRecordSet @@ -85,8 +85,8 @@ func (d *DNSProvider) getHostedZone(domain string) (*sacloud.DNS, error) { return nil, fmt.Errorf("zone %s not found", zoneName) } -func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.DNSRecordSet { - recordName := d.extractRecordName(fqdn, zone.Name) +func findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.DNSRecordSet { + recordName := extractRecordName(fqdn, zone.Name) var res []sacloud.DNSRecordSet for _, record := range zone.Settings.DNS.ResourceRecordSets { @@ -97,9 +97,9 @@ func (d *DNSProvider) findTxtRecords(fqdn string, zone *sacloud.DNS) []sacloud.D return res } -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 diff --git a/providers/dns/vultr/vultr.go b/providers/dns/vultr/vultr.go index f1c915a2..811d27af 100644 --- a/providers/dns/vultr/vultr.go +++ b/providers/dns/vultr/vultr.go @@ -100,7 +100,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { return fmt.Errorf("vultr: %w", err) } - name := d.extractRecordName(fqdn, zoneDomain) + name := extractRecordName(fqdn, zoneDomain) err = d.client.DNSRecord.Create(ctx, zoneDomain, "TXT", name, `"`+value+`"`, d.config.TTL, 0) if err != nil { @@ -175,7 +175,7 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, domain, fqdn string) ( return "", records, fmt.Errorf("API call has failed: %w", err) } - recordName := d.extractRecordName(fqdn, zoneDomain) + recordName := extractRecordName(fqdn, zoneDomain) for _, record := range result { if record.Type == "TXT" && record.Name == recordName { records = append(records, record) @@ -185,9 +185,9 @@ func (d *DNSProvider) findTxtRecords(ctx context.Context, domain, fqdn string) ( return zoneDomain, records, 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