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:
@@ -30,22 +30,22 @@ var defaultNameServerNames = []string{
|
||||
"ns3.systemdns.com",
|
||||
}
|
||||
|
||||
// OpenSRSApi is the api handle.
|
||||
type OpenSRSApi struct {
|
||||
// opensrsAPI is the api handle.
|
||||
type opensrsAPI struct {
|
||||
UserName string // reseller user name
|
||||
ApiKey string // API Key
|
||||
APIKey string // API Key
|
||||
|
||||
BaseURL string // An alternate base URI
|
||||
client *opensrs.Client // Client
|
||||
}
|
||||
|
||||
// GetNameservers returns a list of nameservers.
|
||||
func (c *OpenSRSApi) GetNameservers(domainName string) ([]*models.Nameserver, error) {
|
||||
func (c *opensrsAPI) GetNameservers(domainName string) ([]*models.Nameserver, error) {
|
||||
return models.ToNameservers(defaultNameServerNames)
|
||||
}
|
||||
|
||||
// GetRegistrarCorrections returns a list of corrections for a registrar.
|
||||
func (c *OpenSRSApi) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
func (c *opensrsAPI) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
corrections := []*models.Correction{}
|
||||
|
||||
nameServers, err := c.getNameservers(dc.Name)
|
||||
@@ -77,14 +77,14 @@ func (c *OpenSRSApi) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models
|
||||
|
||||
// OpenSRS calls
|
||||
|
||||
func (c *OpenSRSApi) getClient() *opensrs.Client {
|
||||
func (c *opensrsAPI) getClient() *opensrs.Client {
|
||||
return c.client
|
||||
}
|
||||
|
||||
// Returns the name server names that should be used. If the domain is registered
|
||||
// then this method will return the delegation name servers. If this domain
|
||||
// is hosted only, then it will return the default OpenSRS name servers.
|
||||
func (c *OpenSRSApi) getNameservers(domainName string) ([]string, error) {
|
||||
func (c *opensrsAPI) getNameservers(domainName string) ([]string, error) {
|
||||
client := c.getClient()
|
||||
|
||||
status, err := client.Domains.GetDomain(domainName, "status", 1)
|
||||
@@ -103,7 +103,7 @@ func (c *OpenSRSApi) getNameservers(domainName string) ([]string, error) {
|
||||
}
|
||||
|
||||
// Returns a function that can be invoked to change the delegation of the domain to the given name server names.
|
||||
func (c *OpenSRSApi) updateNameserversFunc(nameServerNames []string, domainName string) func() error {
|
||||
func (c *opensrsAPI) updateNameserversFunc(nameServerNames []string, domainName string) func() error {
|
||||
return func() error {
|
||||
client := c.getClient()
|
||||
|
||||
@@ -121,11 +121,11 @@ func newReg(conf map[string]string) (providers.Registrar, error) {
|
||||
return newProvider(conf, nil)
|
||||
}
|
||||
|
||||
func newProvider(m map[string]string, metadata json.RawMessage) (*OpenSRSApi, error) {
|
||||
api := &OpenSRSApi{}
|
||||
api.ApiKey = m["apikey"]
|
||||
func newProvider(m map[string]string, metadata json.RawMessage) (*opensrsAPI, error) {
|
||||
api := &opensrsAPI{}
|
||||
api.APIKey = m["apikey"]
|
||||
|
||||
if api.ApiKey == "" {
|
||||
if api.APIKey == "" {
|
||||
return nil, fmt.Errorf("openSRS apikey must be provided")
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func newProvider(m map[string]string, metadata json.RawMessage) (*OpenSRSApi, er
|
||||
api.BaseURL = m["baseurl"]
|
||||
}
|
||||
|
||||
api.client = opensrs.NewClient(opensrs.NewApiKeyMD5Credentials(api.UserName, api.ApiKey))
|
||||
api.client = opensrs.NewClient(opensrs.NewApiKeyMD5Credentials(api.UserName, api.APIKey))
|
||||
if api.BaseURL != "" {
|
||||
api.client.BaseURL = api.BaseURL
|
||||
}
|
||||
|
Reference in New Issue
Block a user