github.com/paulmey/terraform@v0.5.2-0.20150519145237-046e9b4c884d/builtin/providers/dme/config.go (about)

     1  package dme
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/soniah/dnsmadeeasy"
     6  	"log"
     7  )
     8  
     9  // Config contains DNSMadeEasy provider settings
    10  type Config struct {
    11  	AKey       string
    12  	SKey       string
    13  	UseSandbox bool
    14  }
    15  
    16  // Client returns a new client for accessing DNSMadeEasy
    17  func (c *Config) Client() (*dnsmadeeasy.Client, error) {
    18  	client, err := dnsmadeeasy.NewClient(c.AKey, c.SKey)
    19  	if err != nil {
    20  		return nil, fmt.Errorf("Error setting up client: %s", err)
    21  	}
    22  
    23  	if c.UseSandbox {
    24  		client.URL = dnsmadeeasy.SandboxURL
    25  	}
    26  
    27  	log.Printf("[INFO] DNSMadeEasy Client configured for AKey: %s", client.AKey)
    28  
    29  	return client, nil
    30  }