Skip to content

Commit

Permalink
dnssimple: use GetZone (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Mar 5, 2025
1 parent 4675ef7 commit c8aa992
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions providers/dns/dnsimple/dnsimple.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,16 @@ func (d *DNSProvider) getHostedZone(domain string) (string, error) {
return "", err
}

zoneName := dns01.UnFqdn(authZone)

zones, err := d.client.Zones.ListZones(context.Background(), accountID, &dnsimple.ZoneListOptions{NameLike: &zoneName})
hostedZone, err := d.client.Zones.GetZone(context.Background(), accountID, dns01.UnFqdn(authZone))
if err != nil {
return "", fmt.Errorf("API call failed: %w", err)
}

var hostedZone dnsimple.Zone
for _, zone := range zones.Data {
if zone.Name == zoneName {
hostedZone = zone
}
return "", fmt.Errorf("get zone: %w", err)
}

if hostedZone.ID == 0 {
if hostedZone == nil || hostedZone.Data == nil || hostedZone.Data.ID == 0 {
return "", fmt.Errorf("zone %s not found in DNSimple for domain %s", authZone, domain)
}

return hostedZone.Name, nil
return hostedZone.Data.Name, nil
}

func (d *DNSProvider) findTxtRecords(fqdn string) ([]dnsimple.ZoneRecord, error) {
Expand Down

0 comments on commit c8aa992

Please sign in to comment.