provider/cloudfront: Minor adjustments for new cloudflare-go lib

This commit is contained in:
clint shryock 2016-06-06 14:57:26 -05:00
parent d70d7aba57
commit 943583925d
2 changed files with 12 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package cloudflare
import (
"fmt"
"log"
"github.com/cloudflare/cloudflare-go"
@ -13,7 +14,10 @@ type Config struct {
// Client() returns a new client for accessing cloudflare.
func (c *Config) Client() (*cloudflare.API, error) {
client := cloudflare.New(c.Token, c.Email)
client, err := cloudflare.New(c.Token, c.Email)
if err != nil {
return nil, fmt.Errorf("Error creating new CloudFlare client: %s", err)
}
log.Printf("[INFO] CloudFlare Client configured for user: %s", c.Email)
return client, nil
}

View File

@ -101,7 +101,13 @@ func resourceCloudFlareRecordCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Failed to create record: %s", err)
}
d.SetId(r.ID)
// In the Event that the API returns an empty DNS Record, we verify that the
// ID returned is not the default ""
if r.Result.ID == "" {
return fmt.Errorf("Failed to find record in Creat response; Record was empty")
}
d.SetId(r.Result.ID)
log.Printf("[INFO] CloudFlare Record ID: %s", d.Id())