forked from TrueCloudLab/lego
otc: select correct zone if multiple returned (#1292)
This commit is contained in:
parent
3158518511
commit
95bae8c50d
2 changed files with 9 additions and 9 deletions
|
@ -69,6 +69,7 @@ type endpoint struct {
|
|||
|
||||
type zoneItem struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type zonesResponse struct {
|
||||
|
@ -182,15 +183,13 @@ func (d *DNSProvider) getZoneID(zone string) (string, error) {
|
|||
return "", fmt.Errorf("zone %s not found", zone)
|
||||
}
|
||||
|
||||
if len(zonesRes.Zones) > 1 {
|
||||
return "", errors.New("to many zones found")
|
||||
for _, z := range zonesRes.Zones {
|
||||
if z.Name == zone {
|
||||
return z.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
if zonesRes.Zones[0].ID == "" {
|
||||
return "", errors.New("id not found")
|
||||
}
|
||||
|
||||
return zonesRes.Zones[0].ID, nil
|
||||
return "", fmt.Errorf("zone %s not found", zone)
|
||||
}
|
||||
|
||||
func (d *DNSProvider) getRecordSetID(zoneID, fqdn string) (string, error) {
|
||||
|
|
|
@ -76,7 +76,8 @@ func (m *DNSServerMock) HandleListZonesSuccessfully() {
|
|||
|
||||
fmt.Fprintf(w, `{
|
||||
"zones":[{
|
||||
"id":"123123"
|
||||
"id":"123123",
|
||||
"name":"example.com."
|
||||
}]}
|
||||
`)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue