forked from TrueCloudLab/lego
rackspace: change zone ID to string (#1508)
This commit is contained in:
parent
dfa0a6da68
commit
88f62f106d
3 changed files with 11 additions and 11 deletions
|
@ -62,7 +62,7 @@ type ZoneSearchResponse struct {
|
||||||
|
|
||||||
// HostedZone HostedZone.
|
// HostedZone HostedZone.
|
||||||
type HostedZone struct {
|
type HostedZone struct {
|
||||||
ID int `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,34 +82,34 @@ type Record struct {
|
||||||
|
|
||||||
// getHostedZoneID performs a lookup to get the DNS zone which needs
|
// getHostedZoneID performs a lookup to get the DNS zone which needs
|
||||||
// modifying for a given FQDN.
|
// modifying for a given FQDN.
|
||||||
func (d *DNSProvider) getHostedZoneID(fqdn string) (int, error) {
|
func (d *DNSProvider) getHostedZoneID(fqdn string) (string, error) {
|
||||||
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains?name=%s", dns01.UnFqdn(authZone)), nil)
|
result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains?name=%s", dns01.UnFqdn(authZone)), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var zoneSearchResponse ZoneSearchResponse
|
var zoneSearchResponse ZoneSearchResponse
|
||||||
err = json.Unmarshal(result, &zoneSearchResponse)
|
err = json.Unmarshal(result, &zoneSearchResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If nothing was returned, or for whatever reason more than 1 was returned (the search uses exact match, so should not occur)
|
// If nothing was returned, or for whatever reason more than 1 was returned (the search uses exact match, so should not occur)
|
||||||
if zoneSearchResponse.TotalEntries != 1 {
|
if zoneSearchResponse.TotalEntries != 1 {
|
||||||
return 0, fmt.Errorf("found %d zones for %s in Rackspace for domain %s", zoneSearchResponse.TotalEntries, authZone, fqdn)
|
return "", fmt.Errorf("found %d zones for %s in Rackspace for domain %s", zoneSearchResponse.TotalEntries, authZone, fqdn)
|
||||||
}
|
}
|
||||||
|
|
||||||
return zoneSearchResponse.HostedZones[0].ID, nil
|
return zoneSearchResponse.HostedZones[0].ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findTxtRecord searches a DNS zone for a TXT record with a specific name.
|
// findTxtRecord searches a DNS zone for a TXT record with a specific name.
|
||||||
func (d *DNSProvider) findTxtRecord(fqdn string, zoneID int) (*Record, error) {
|
func (d *DNSProvider) findTxtRecord(fqdn string, zoneID string) (*Record, error) {
|
||||||
result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains/%d/records?type=TXT&name=%s", zoneID, dns01.UnFqdn(fqdn)), nil)
|
result, err := d.makeRequest(http.MethodGet, fmt.Sprintf("/domains/%s/records?type=TXT&name=%s", zoneID, dns01.UnFqdn(fqdn)), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
|
||||||
return fmt.Errorf("rackspace: %w", err)
|
return fmt.Errorf("rackspace: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = d.makeRequest(http.MethodPost, fmt.Sprintf("/domains/%d/records", zoneID), bytes.NewReader(body))
|
_, err = d.makeRequest(http.MethodPost, fmt.Sprintf("/domains/%s/records", zoneID), bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("rackspace: %w", err)
|
return fmt.Errorf("rackspace: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
return fmt.Errorf("rackspace: %w", err)
|
return fmt.Errorf("rackspace: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = d.makeRequest(http.MethodDelete, fmt.Sprintf("/domains/%d/records?id=%s", zoneID, record.ID), nil)
|
_, err = d.makeRequest(http.MethodDelete, fmt.Sprintf("/domains/%s/records?id=%s", zoneID, record.ID), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("rackspace: %w", err)
|
return fmt.Errorf("rackspace: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ const zoneDetailsMock = `
|
||||||
"domains": [
|
"domains": [
|
||||||
{
|
{
|
||||||
"name": "example.com",
|
"name": "example.com",
|
||||||
"id": 112233,
|
"id": "112233",
|
||||||
"emailAddress": "hostmaster@example.com",
|
"emailAddress": "hostmaster@example.com",
|
||||||
"updated": "1970-01-01T00:00:00.000+0000",
|
"updated": "1970-01-01T00:00:00.000+0000",
|
||||||
"created": "1970-01-01T00:00:00.000+0000"
|
"created": "1970-01-01T00:00:00.000+0000"
|
||||||
|
|
Loading…
Reference in a new issue