This commit is contained in:
Madhu 2014-11-10 18:44:23 -08:00
commit 5ed2ee8f37
5 changed files with 25 additions and 10 deletions

View File

@ -2,6 +2,7 @@ package digitalocean
import (
"log"
"os"
"github.com/pearkes/digitalocean"
)
@ -14,6 +15,13 @@ type Config struct {
// ocean.
//
func (c *Config) Client() (*digitalocean.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("DIGITALOCEAN_TOKEN"); v != "" {
c.Token = v
}
client, err := digitalocean.NewClient(c.Token)
log.Printf("[INFO] DigitalOcean Client configured for URL: %s", client.URL)

View File

@ -296,7 +296,7 @@ func resource_digitalocean_droplet_update_state(
s.Attributes["ipv4_address_private"] = droplet.IPV4Address("private")
}
s.Attributes["size"] = droplet.SizeSlug()
s.Attributes["size"] = droplet.SizeSlug
s.Attributes["status"] = droplet.Status
return s, nil

View File

@ -123,8 +123,8 @@ func testAccCheckDigitalOceanDropletAttributes(droplet *digitalocean.Droplet) re
return fmt.Errorf("Bad image_slug: %s", droplet.ImageSlug())
}
if droplet.SizeSlug() != "512mb" {
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug())
if droplet.SizeSlug != "512mb" {
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug)
}
if droplet.RegionSlug() != "nyc3" {
@ -141,8 +141,8 @@ func testAccCheckDigitalOceanDropletAttributes(droplet *digitalocean.Droplet) re
func testAccCheckDigitalOceanDropletRenamedAndResized(droplet *digitalocean.Droplet) resource.TestCheckFunc {
return func(s *terraform.State) error {
if droplet.SizeSlug() != "1gb" {
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug())
if droplet.SizeSlug != "1gb" {
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug)
}
if droplet.Name != "baz" {
@ -160,8 +160,8 @@ func testAccCheckDigitalOceanDropletAttributes_PrivateNetworkingIpv6(droplet *di
return fmt.Errorf("Bad image_slug: %s", droplet.ImageSlug())
}
if droplet.SizeSlug() != "1gb" {
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug())
if droplet.SizeSlug != "1gb" {
return fmt.Errorf("Bad size_slug: %s", droplet.SizeSlug)
}
if droplet.RegionSlug() != "sgp1" {

View File

@ -25,9 +25,16 @@ func TestResourceProvider_impl(t *testing.T) {
func TestResourceProvider_Configure(t *testing.T) {
rp := new(ResourceProvider)
var expectedToken string
if v := os.Getenv("DIGITALOCEAN_TOKEN"); v != "foo" {
expectedToken = v
} else {
expectedToken = "foo"
}
raw := map[string]interface{}{
"token": "foo",
"token": expectedToken,
}
rawConfig, err := config.NewRawConfig(raw)
@ -41,7 +48,7 @@ func TestResourceProvider_Configure(t *testing.T) {
}
expected := Config{
Token: "foo",
Token: expectedToken,
}
if !reflect.DeepEqual(rp.Config, expected) {

View File

@ -23,7 +23,7 @@ resource "aws_db_instance" "default" {
username = "foo"
password = "bar"
security_group_names = ["${aws_db_security_group.bar.name}"]
subnet_group_name = "my_database_subnet_group"
db_subnet_group_name = "my_database_subnet_group"
}
```