forked from hashicorp/terraform
/
config.go
36 lines (28 loc) · 807 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package dnsimple
import (
"log"
"github.com/dnsimple/dnsimple-go/dnsimple"
"github.com/hashicorp/terraform/terraform"
)
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
}
// 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()
provider := &Client{
client: client,
config: c,
}
log.Printf("[INFO] DNSimple Client configured for account: %s", c.Account)
return provider, nil
}