mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Be more consistent in API handle variable names (#911)
This commit is contained in:
@@ -15,7 +15,7 @@ const (
|
||||
domainsPath = "domains"
|
||||
)
|
||||
|
||||
func (c *LinodeAPI) fetchDomainList() error {
|
||||
func (c *linodeAPI) fetchDomainList() error {
|
||||
c.domainIndex = map[string]int{}
|
||||
page := 1
|
||||
for {
|
||||
@@ -35,7 +35,7 @@ func (c *LinodeAPI) fetchDomainList() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) getRecords(id int) ([]domainRecord, error) {
|
||||
func (c *linodeAPI) getRecords(id int) ([]domainRecord, error) {
|
||||
records := []domainRecord{}
|
||||
page := 1
|
||||
for {
|
||||
@@ -56,7 +56,7 @@ func (c *LinodeAPI) getRecords(id int) ([]domainRecord, error) {
|
||||
return records, nil
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) createRecord(domainID int, rec *recordEditRequest) (*domainRecord, error) {
|
||||
func (c *linodeAPI) createRecord(domainID int, rec *recordEditRequest) (*domainRecord, error) {
|
||||
endpoint := fmt.Sprintf("%s/%d/records", domainsPath, domainID)
|
||||
|
||||
req, err := c.newRequest(http.MethodPost, endpoint, rec)
|
||||
@@ -84,7 +84,7 @@ func (c *LinodeAPI) createRecord(domainID int, rec *recordEditRequest) (*domainR
|
||||
return record, nil
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) modifyRecord(domainID, recordID int, rec *recordEditRequest) error {
|
||||
func (c *linodeAPI) modifyRecord(domainID, recordID int, rec *recordEditRequest) error {
|
||||
endpoint := fmt.Sprintf("%s/%d/records/%d", domainsPath, domainID, recordID)
|
||||
|
||||
req, err := c.newRequest(http.MethodPut, endpoint, rec)
|
||||
@@ -104,7 +104,7 @@ func (c *LinodeAPI) modifyRecord(domainID, recordID int, rec *recordEditRequest)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) deleteRecord(domainID, recordID int) error {
|
||||
func (c *linodeAPI) deleteRecord(domainID, recordID int) error {
|
||||
endpoint := fmt.Sprintf("%s/%d/records/%d", domainsPath, domainID, recordID)
|
||||
req, err := c.newRequest(http.MethodDelete, endpoint, nil)
|
||||
if err != nil {
|
||||
@@ -123,7 +123,7 @@ func (c *LinodeAPI) deleteRecord(domainID, recordID int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) newRequest(method, endpoint string, body interface{}) (*http.Request, error) {
|
||||
func (c *linodeAPI) newRequest(method, endpoint string, body interface{}) (*http.Request, error) {
|
||||
rel, err := url.Parse(endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -149,7 +149,7 @@ func (c *LinodeAPI) newRequest(method, endpoint string, body interface{}) (*http
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) get(endpoint string, target interface{}) error {
|
||||
func (c *linodeAPI) get(endpoint string, target interface{}) error {
|
||||
req, err := c.newRequest(http.MethodGet, endpoint, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -166,7 +166,7 @@ func (c *LinodeAPI) get(endpoint string, target interface{}) error {
|
||||
return decoder.Decode(target)
|
||||
}
|
||||
|
||||
func (c *LinodeAPI) handleErrors(resp *http.Response) error {
|
||||
func (c *linodeAPI) handleErrors(resp *http.Response) error {
|
||||
defer resp.Body.Close()
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
|
||||
|
@@ -43,8 +43,8 @@ var allowedTTLValues = []uint32{
|
||||
|
||||
var srvRegexp = regexp.MustCompile(`^_(?P<Service>\w+)\.\_(?P<Protocol>\w+)$`)
|
||||
|
||||
// LinodeAPI is the handle for this provider.
|
||||
type LinodeAPI struct {
|
||||
// linodeAPI is the handle for this provider.
|
||||
type linodeAPI struct {
|
||||
client *http.Client
|
||||
baseURL *url.URL
|
||||
domainIndex map[string]int
|
||||
@@ -75,7 +75,7 @@ func NewLinode(m map[string]string, metadata json.RawMessage) (providers.DNSServ
|
||||
return nil, fmt.Errorf("invalid base URL for Linode")
|
||||
}
|
||||
|
||||
api := &LinodeAPI{client: client, baseURL: baseURL}
|
||||
api := &linodeAPI{client: client, baseURL: baseURL}
|
||||
|
||||
// Get a domain to validate the token
|
||||
if err := api.fetchDomainList(); err != nil {
|
||||
@@ -97,12 +97,12 @@ func init() {
|
||||
}
|
||||
|
||||
// GetNameservers returns the nameservers for a domain.
|
||||
func (api *LinodeAPI) GetNameservers(domain string) ([]*models.Nameserver, error) {
|
||||
func (api *linodeAPI) GetNameservers(domain string) ([]*models.Nameserver, error) {
|
||||
return models.ToNameservers(defaultNameServerNames)
|
||||
}
|
||||
|
||||
// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
|
||||
func (api *LinodeAPI) GetZoneRecords(domain string) (models.Records, error) {
|
||||
func (api *linodeAPI) GetZoneRecords(domain string) (models.Records, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
// This enables the get-zones subcommand.
|
||||
// Implement this by extracting the code from GetDomainCorrections into
|
||||
@@ -110,7 +110,7 @@ func (api *LinodeAPI) GetZoneRecords(domain string) (models.Records, error) {
|
||||
}
|
||||
|
||||
// GetDomainCorrections returns the corrections for a domain.
|
||||
func (api *LinodeAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
func (api *linodeAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
dc, err := dc.Copy()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user