1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Vet and Lint the entire system (#296)

* govet and golint corrections
This commit is contained in:
Tom Limoncelli
2018-01-09 12:53:16 -05:00
committed by GitHub
parent 1a91a7f536
commit b7c251190f
64 changed files with 540 additions and 433 deletions

View File

@@ -173,10 +173,10 @@ func (c *LinodeApi) handleErrors(resp *http.Response) error {
errs := &errorResponse{}
if err := decoder.Decode(errs); err != nil {
return fmt.Errorf("Bad status code from Linode: %d not 200. Failed to decode response.", resp.StatusCode)
return fmt.Errorf("bad status code from Linode: %d not 200. Failed to decode response", resp.StatusCode)
}
buf := bytes.NewBufferString(fmt.Sprintf("Bad status code from Linode: %d not 200.", resp.StatusCode))
buf := bytes.NewBufferString(fmt.Sprintf("bad status code from Linode: %d not 200", resp.StatusCode))
for _, err := range errs.Errors {
buf.WriteString("\n- ")

View File

@@ -45,6 +45,7 @@ var allowedTTLValues = []uint32{
var srvRegexp = regexp.MustCompile(`^_(?P<Service>\w+)\.\_(?P<Protocol>\w+)$`)
// LinodeApi is the handle for this provider.
type LinodeApi struct {
client *http.Client
baseURL *url.URL
@@ -59,9 +60,10 @@ var defaultNameServerNames = []string{
"ns5.linode.com",
}
// NewLinode creates the provider.
func NewLinode(m map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) {
if m["token"] == "" {
return nil, fmt.Errorf("Linode Token must be provided.")
return nil, fmt.Errorf("Missing Linode token")
}
ctx := context.Background()
@@ -95,10 +97,12 @@ func init() {
providers.RegisterDomainServiceProviderType("LINODE", NewLinode, features)
}
// GetNameservers returns the nameservers for a domain.
func (api *LinodeApi) GetNameservers(domain string) ([]*models.Nameserver, error) {
return models.StringsToNameservers(defaultNameServerNames), nil
}
// GetDomainCorrections returns the corrections for a domain.
func (api *LinodeApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
dc, err := dc.Copy()
if err != nil {
@@ -293,9 +297,8 @@ func fixTarget(target, domain string) string {
// Linode always wants a fully qualified target name
if target[len(target)-1] == '.' {
return target[:len(target)-1]
} else {
return fmt.Sprintf("%s.%s", target, domain)
}
return fmt.Sprintf("%s.%s", target, domain)
}
func fixTTL(ttl uint32) uint32 {