Skip to content

Commit 48662a5

Browse files
committed
dnssimple: use GetZone
1 parent 4675ef7 commit 48662a5

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

providers/dns/dnsimple/dnsimple.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,16 @@ func (d *DNSProvider) getHostedZone(domain string) (string, error) {
161161
return "", err
162162
}
163163

164-
zoneName := dns01.UnFqdn(authZone)
165-
166-
zones, err := d.client.Zones.ListZones(context.Background(), accountID, &dnsimple.ZoneListOptions{NameLike: &zoneName})
164+
hostedZone, err := d.client.Zones.GetZone(context.Background(), accountID, dns01.UnFqdn(authZone))
167165
if err != nil {
168-
return "", fmt.Errorf("API call failed: %w", err)
169-
}
170-
171-
var hostedZone dnsimple.Zone
172-
for _, zone := range zones.Data {
173-
if zone.Name == zoneName {
174-
hostedZone = zone
175-
}
166+
return "", fmt.Errorf("get zone: %w", err)
176167
}
177168

178-
if hostedZone.ID == 0 {
169+
if hostedZone.Data.ID == 0 {
179170
return "", fmt.Errorf("zone %s not found in DNSimple for domain %s", authZone, domain)
180171
}
181172

182-
return hostedZone.Name, nil
173+
return hostedZone.Data.Name, nil
183174
}
184175

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

0 commit comments

Comments
 (0)