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

@@ -24,6 +24,7 @@ Info required in `creds.json`:
*/
// DoApi is the handle for operations.
type DoApi struct {
client *godo.Client
}
@@ -34,9 +35,10 @@ var defaultNameServerNames = []string{
"ns3.digitalocean.com",
}
// NewDo creates a DO-specific DNS provider.
func NewDo(m map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) {
if m["token"] == "" {
return nil, fmt.Errorf("Digitalocean Token must be provided.")
return nil, fmt.Errorf("no Digitalocean token provided")
}
ctx := context.Background()
@@ -54,7 +56,7 @@ func NewDo(m map[string]string, metadata json.RawMessage) (providers.DNSServiceP
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Digitalocean Token is not valid.")
return nil, fmt.Errorf("token for digitalocean is not valid")
}
return api, nil
@@ -70,6 +72,7 @@ func init() {
providers.RegisterDomainServiceProviderType("DIGITALOCEAN", NewDo, features)
}
// EnsureDomainExists returns an error if domain doesn't exist.
func (api *DoApi) EnsureDomainExists(domain string) error {
ctx := context.Background()
_, resp, err := api.client.Domains.Get(ctx, domain)
@@ -79,15 +82,16 @@ func (api *DoApi) EnsureDomainExists(domain string) error {
IPAddress: "",
})
return err
} else {
return err
}
return err
}
// GetNameservers returns the nameservers for domain.
func (api *DoApi) GetNameservers(domain string) ([]*models.Nameserver, error) {
return models.StringsToNameservers(defaultNameServerNames), nil
}
// GetDomainCorrections returns a list of corretions for the domain.
func (api *DoApi) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
ctx := context.Background()
dc.Punycode()