github.com/richardbowden/terraform@v0.6.12-0.20160901200758-30ea22c25211/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  }