terraform/builtin/providers/dme/config.go

35 lines
656 B
Go
Raw Normal View History

package dme
import (
"fmt"
"log"
"net/http"
"github.com/soniah/dnsmadeeasy"
)
// Config contains DNSMadeEasy provider settings
type Config struct {
AKey string
SKey string
UseSandbox bool
}
// Client returns a new client for accessing DNSMadeEasy
func (c *Config) Client() (*dnsmadeeasy.Client, error) {
client, err := dnsmadeeasy.NewClient(c.AKey, c.SKey)
if err != nil {
return nil, fmt.Errorf("Error setting up client: %s", err)
}
client.HTTP = &http.Client{}
if c.UseSandbox {
client.URL = dnsmadeeasy.SandboxURL
}
log.Printf("[INFO] DNSMadeEasy Client configured for AKey: %s", client.AKey)
return client, nil
}