terraform/builtin/providers/dme/config.go

35 lines
692 B
Go
Raw Normal View History

package dme
import (
"fmt"
"log"
2015-10-22 20:03:25 +02:00
"github.com/hashicorp/go-cleanhttp"
"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)
}
2015-10-22 20:03:25 +02:00
client.HTTP = cleanhttp.DefaultClient()
if c.UseSandbox {
client.URL = dnsmadeeasy.SandboxURL
}
log.Printf("[INFO] DNSMadeEasy Client configured for AKey: %s", client.AKey)
return client, nil
}