github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/fastly/config.go (about)

     1  package fastly
     2  
     3  import (
     4  	"fmt"
     5  
     6  	gofastly "github.com/sethvargo/go-fastly"
     7  )
     8  
     9  type Config struct {
    10  	ApiKey string
    11  }
    12  
    13  type FastlyClient struct {
    14  	conn *gofastly.Client
    15  }
    16  
    17  func (c *Config) Client() (interface{}, error) {
    18  	var client FastlyClient
    19  
    20  	if c.ApiKey == "" {
    21  		return nil, fmt.Errorf("[Err] No API key for Fastly")
    22  	}
    23  
    24  	fconn, err := gofastly.NewClient(c.ApiKey)
    25  	if err != nil {
    26  		return nil, err
    27  	}
    28  
    29  	client.conn = fconn
    30  	return &client, nil
    31  }