terraform/builtin/providers/digitalocean/config.go

26 lines
515 B
Go
Raw Normal View History

2014-07-19 02:20:28 +02:00
package digitalocean
import (
"log"
"github.com/digitalocean/godo"
"golang.org/x/oauth2"
2014-07-19 02:20:28 +02:00
)
type Config struct {
Token string
2014-07-19 02:20:28 +02:00
}
// Client() returns a new client for accessing digital ocean.
func (c *Config) Client() (*godo.Client, error) {
tokenSrc := oauth2.StaticTokenSource(&oauth2.Token{
AccessToken: c.Token,
})
2014-07-19 02:20:28 +02:00
client := godo.NewClient(oauth2.NewClient(oauth2.NoContext, tokenSrc))
2014-07-19 02:20:28 +02:00
log.Printf("[INFO] DigitalOcean Client configured for URL: %s", client.BaseURL.String())
2014-07-19 02:20:28 +02:00
return client, nil
}