provider/cloudfront: Minor adjustments for new cloudflare-go lib
This commit is contained in:
parent
d70d7aba57
commit
943583925d
|
@ -1,6 +1,7 @@
|
||||||
package cloudflare
|
package cloudflare
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/cloudflare/cloudflare-go"
|
"github.com/cloudflare/cloudflare-go"
|
||||||
|
@ -13,7 +14,10 @@ type Config struct {
|
||||||
|
|
||||||
// Client() returns a new client for accessing cloudflare.
|
// Client() returns a new client for accessing cloudflare.
|
||||||
func (c *Config) Client() (*cloudflare.API, error) {
|
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)
|
log.Printf("[INFO] CloudFlare Client configured for user: %s", c.Email)
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,13 @@ func resourceCloudFlareRecordCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
return fmt.Errorf("Failed to create record: %s", err)
|
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())
|
log.Printf("[INFO] CloudFlare Record ID: %s", d.Id())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue