2014-07-25 18:21:15 +02:00
|
|
|
package cloudflare
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/pearkes/cloudflare"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2014-11-17 18:57:41 +01:00
|
|
|
Email string
|
|
|
|
Token string
|
2014-07-25 18:21:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Client() returns a new client for accessing cloudflare.
|
|
|
|
func (c *Config) Client() (*cloudflare.Client, error) {
|
|
|
|
client, err := cloudflare.NewClient(c.Email, c.Token)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Error setting up client: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("[INFO] CloudFlare Client configured for user: %s", client.Email)
|
|
|
|
|
|
|
|
return client, nil
|
|
|
|
}
|