예제 #1
0
// NewDNSClient creates a new DNS client instance for the given credentials.
func NewDNSClient(credentials APICredentials) (DNSClient, error) {
	dnsimpleClient, dnsimpleClientError := dnsimple.NewClient(credentials.Email, credentials.Token)
	if dnsimpleClientError != nil {
		return nil, fmt.Errorf("Unable to create DNSimple client. Error: %s", dnsimpleClientError.Error())
	}

	return dnsimpleClient, nil
}
예제 #2
0
// Client() returns a new client for accessing dnsimple.
func (c *Config) Client() (*dnsimple.Client, error) {
	client, err := dnsimple.NewClient(c.Email, c.Token)

	if err != nil {
		return nil, fmt.Errorf("Error setting up client: %s", err)
	}

	log.Printf("[INFO] DNSimple Client configured for user: %s", client.Email)

	return client, nil
}
예제 #3
0
파일: config.go 프로젝트: EZTABLE/terraform
// Client() returns a new client for accessing dnsimple.
//
func (c *Config) Client() (*dnsimple.Client, error) {

	// If we have env vars set (like in the acc) tests,
	// we need to override the values passed in here.
	if v := os.Getenv("DNSIMPLE_EMAIL"); v != "" {
		c.Email = v
	}
	if v := os.Getenv("DNSIMPLE_TOKEN"); v != "" {
		c.Token = v
	}

	client, err := dnsimple.NewClient(c.Email, c.Token)

	if err != nil {
		return nil, fmt.Errorf("Error setting up client: %s", err)
	}

	log.Printf("[INFO] DNSimple Client configured for user: %s", client.Email)

	return client, nil
}