github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/cloudflare/config.go (about)

     1  package cloudflare
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  
     7  	"github.com/cloudflare/cloudflare-go"
     8  )
     9  
    10  type Config struct {
    11  	Email string
    12  	Token string
    13  }
    14  
    15  // Client() returns a new client for accessing cloudflare.
    16  func (c *Config) Client() (*cloudflare.API, error) {
    17  	client, err := cloudflare.New(c.Token, c.Email)
    18  	if err != nil {
    19  		return nil, fmt.Errorf("Error creating new CloudFlare client: %s", err)
    20  	}
    21  	log.Printf("[INFO] CloudFlare Client configured for user: %s", c.Email)
    22  	return client, nil
    23  }