mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Switch to Go 1.13 error wrapping (#604)
* Replaced errors.Wrap with fmt.Errorf (#589) * Find: errors\.Wrap\(([^,]+),\s+(["`][^"`]*)(["`])\) Replace: fmt.Errorf($2: %w$3, $1) * Replaced errors.Wrapf with fmt.Errorf (#589) * Find: errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])\) Replace: fmt.Errorf($2: %w$3, $1) * Find: errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])(,[^)]+)\) * Replace: fmt.Errorf($2: %w$3$4, $1) * Replaced errors.Errorf with fmt.Errorf (#589) * Find: errors\.Errorf Replace: fmt.Errorf * Cleaned up remaining imports * Cleanup * Regenerate provider support matrix This was broken by #533 ... and it's now the third time this has been missed.
This commit is contained in:
committed by
Tom Limoncelli
parent
cae35a2c8f
commit
825ba2d081
@@ -2,7 +2,7 @@ package cloudns
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -86,7 +86,7 @@ func (c *api) fetchAvailableNameservers() error {
|
||||
|
||||
var bodyString, err = c.get("/dns/available-name-servers.json", requestParams{})
|
||||
if err != nil {
|
||||
return errors.Errorf("Error fetching available nameservers list from ClouDNS: %s", err)
|
||||
return fmt.Errorf("Error fetching available nameservers list from ClouDNS: %s", err)
|
||||
}
|
||||
|
||||
var nr nameserverResponse
|
||||
@@ -114,7 +114,7 @@ func (c *api) fetchDomainList() error {
|
||||
endpoint := "/dns/list-zones.json"
|
||||
var bodyString, err = c.get(endpoint, params)
|
||||
if err != nil {
|
||||
return errors.Errorf("Error fetching domain list from ClouDNS: %s", err)
|
||||
return fmt.Errorf("Error fetching domain list from ClouDNS: %s", err)
|
||||
}
|
||||
json.Unmarshal(bodyString, &dr)
|
||||
|
||||
@@ -135,7 +135,7 @@ func (c *api) createDomain(domain string) error {
|
||||
"zone-type": "master",
|
||||
}
|
||||
if _, err := c.get("/dns/register.json", params); err != nil {
|
||||
return errors.Errorf("Error create domain ClouDNS: %s", err)
|
||||
return fmt.Errorf("Error create domain ClouDNS: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (c *api) createDomain(domain string) error {
|
||||
func (c *api) createRecord(domainID string, rec requestParams) error {
|
||||
rec["domain-name"] = domainID
|
||||
if _, err := c.get("/dns/add-record.json", rec); err != nil {
|
||||
return errors.Errorf("Error create record ClouDNS: %s", err)
|
||||
return fmt.Errorf("Error create record ClouDNS: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func (c *api) deleteRecord(domainID string, recordID string) error {
|
||||
"record-id": recordID,
|
||||
}
|
||||
if _, err := c.get("/dns/delete-record.json", params); err != nil {
|
||||
return errors.Errorf("Error delete record ClouDNS: %s", err)
|
||||
return fmt.Errorf("Error delete record ClouDNS: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -163,7 +163,7 @@ func (c *api) modifyRecord(domainID string, recordID string, rec requestParams)
|
||||
rec["domain-name"] = domainID
|
||||
rec["record-id"] = recordID
|
||||
if _, err := c.get("/dns/mod-record.json", rec); err != nil {
|
||||
return errors.Errorf("Error create update ClouDNS: %s", err)
|
||||
return fmt.Errorf("Error create update ClouDNS: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func (c *api) getRecords(id string) ([]domainRecord, error) {
|
||||
|
||||
var bodyString, err = c.get("/dns/records.json", params)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Error fetching record list from ClouDNS: %s", err)
|
||||
return nil, fmt.Errorf("Error fetching record list from ClouDNS: %s", err)
|
||||
}
|
||||
|
||||
var dr recordResponse
|
||||
@@ -213,7 +213,7 @@ func (c *api) get(endpoint string, params requestParams) ([]byte, error) {
|
||||
var errResp errorResponse
|
||||
err = json.Unmarshal(bodyString, &errResp)
|
||||
if errResp.Status == "Failed" {
|
||||
return bodyString, errors.Errorf("ClouDNS API error: %s URL:%s%s ", errResp.Description, req.Host, req.URL.RequestURI())
|
||||
return bodyString, fmt.Errorf("ClouDNS API error: %s URL:%s%s ", errResp.Description, req.Host, req.URL.RequestURI())
|
||||
}
|
||||
|
||||
return bodyString, nil
|
||||
|
@@ -3,12 +3,13 @@ package cloudns
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v2/models"
|
||||
"github.com/StackExchange/dnscontrol/v2/providers"
|
||||
"github.com/StackExchange/dnscontrol/v2/providers/diff"
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
"github.com/pkg/errors"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -27,7 +28,7 @@ func NewCloudns(m map[string]string, metadata json.RawMessage) (providers.DNSSer
|
||||
|
||||
c.creds.id, c.creds.password = m["auth-id"], m["auth-password"]
|
||||
if c.creds.id == "" || c.creds.password == "" {
|
||||
return nil, errors.Errorf("missing ClouDNS auth-id and auth-password")
|
||||
return nil, fmt.Errorf("missing ClouDNS auth-id and auth-password")
|
||||
}
|
||||
|
||||
// Get a domain to validate authentication
|
||||
@@ -78,7 +79,7 @@ func (c *api) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correctio
|
||||
}
|
||||
domainID, ok := c.domainIndex[dc.Name]
|
||||
if !ok {
|
||||
return nil, errors.Errorf("%s not listed in domains for ClouDNS account", dc.Name)
|
||||
return nil, fmt.Errorf("%s not listed in domains for ClouDNS account", dc.Name)
|
||||
}
|
||||
|
||||
records, err := c.getRecords(domainID)
|
||||
|
Reference in New Issue
Block a user