terraform/builtin/providers/dnsimple/config.go

37 lines
807 B
Go
Raw Normal View History

2014-07-23 23:43:28 +02:00
package dnsimple
import (
"log"
"github.com/dnsimple/dnsimple-go/dnsimple"
"github.com/hashicorp/terraform/terraform"
2014-07-23 23:43:28 +02:00
)
type Config struct {
Email string
Account string
Token string
}
// Client represents the DNSimple provider client.
// This is a convenient container for the configuration and the underlying API client.
type Client struct {
client *dnsimple.Client
config *Config
2014-07-23 23:43:28 +02:00
}
2014-07-25 18:05:51 +02:00
// Client() returns a new client for accessing dnsimple.
func (c *Config) Client() (*Client, error) {
client := dnsimple.NewClient(dnsimple.NewOauthTokenCredentials(c.Token))
client.UserAgent = "HashiCorp-Terraform/" + terraform.VersionString()
2014-07-24 16:21:39 +02:00
provider := &Client{
client: client,
config: c,
2014-07-24 16:21:39 +02:00
}
2014-07-23 23:43:28 +02:00
log.Printf("[INFO] DNSimple Client configured for account: %s", c.Account)
2014-07-23 23:43:28 +02:00
return provider, nil
2014-07-23 23:43:28 +02:00
}