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 {
|
type zoneItem struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type zonesResponse struct {
|
type zonesResponse struct {
|
||||||
|
@ -182,15 +183,13 @@ func (d *DNSProvider) getZoneID(zone string) (string, error) {
|
||||||
return "", fmt.Errorf("zone %s not found", zone)
|
return "", fmt.Errorf("zone %s not found", zone)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(zonesRes.Zones) > 1 {
|
for _, z := range zonesRes.Zones {
|
||||||
return "", errors.New("to many zones found")
|
if z.Name == zone {
|
||||||
|
return z.ID, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if zonesRes.Zones[0].ID == "" {
|
return "", fmt.Errorf("zone %s not found", zone)
|
||||||
return "", errors.New("id not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
return zonesRes.Zones[0].ID, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DNSProvider) getRecordSetID(zoneID, fqdn string) (string, error) {
|
func (d *DNSProvider) getRecordSetID(zoneID, fqdn string) (string, error) {
|
||||||
|
|
|
@ -76,7 +76,8 @@ func (m *DNSServerMock) HandleListZonesSuccessfully() {
|
||||||
|
|
||||||
fmt.Fprintf(w, `{
|
fmt.Fprintf(w, `{
|
||||||
"zones":[{
|
"zones":[{
|
||||||
"id":"123123"
|
"id":"123123",
|
||||||
|
"name":"example.com."
|
||||||
}]}
|
}]}
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue