providers/heroku: name and region are now required

cc/ @catsby if you're curious. That fixed the acceptance tests,
thought there is still one (different issue) that is still failing.

Also, it nows construct a transport instead of using the default
and setting the auth globally. TF could potentially run things
concurrently and that might go wrong.
This commit is contained in:
Jack Pearkes 2014-08-27 15:50:38 -07:00
parent 18cb0f09b9
commit 02d18d67b8
8 changed files with 21 additions and 20 deletions

View File

@ -2,6 +2,7 @@ package heroku
import (
"log"
"net/http"
"os"
"github.com/cyberdelia/heroku-go/v3"
@ -25,12 +26,15 @@ func (c *Config) Client() (*heroku.Service, error) {
c.APIKey = v
}
heroku.DefaultTransport.Username = c.Email
heroku.DefaultTransport.Password = c.APIKey
client := heroku.NewService(heroku.DefaultClient)
service := heroku.NewService(&http.Client{
Transport: &heroku.Transport{
Username: c.Email,
Password: c.APIKey,
UserAgent: heroku.DefaultUserAgent,
},
})
log.Printf("[INFO] Heroku Client configured for user: %s", c.Email)
return client, nil
return service, nil
}

View File

@ -4,7 +4,6 @@ import (
"os"
"testing"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
@ -61,13 +60,6 @@ func TestProviderConfigure(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
if heroku.DefaultTransport.Username != expectedEmail {
t.Fatalf("bad: %#v", heroku.DefaultTransport)
}
if heroku.DefaultTransport.Password != expectedKey {
t.Fatalf("bad: %#v", heroku.DefaultTransport)
}
}
func testAccPreCheck(t *testing.T) {

View File

@ -96,6 +96,7 @@ func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestC
const testAccCheckHerokuAddonConfig_basic = `
resource "heroku_app" "foobar" {
name = "terraform-test-app"
region = "us"
}
resource "heroku_addon" "foobar" {

View File

@ -50,14 +50,13 @@ func resourceHerokuApp() *schema.Resource {
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Required: true,
},
"region": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Required: true,
ForceNew: true,
},
"stack": &schema.Schema{

View File

@ -230,6 +230,7 @@ func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFu
const testAccCheckHerokuAppConfig_basic = `
resource "heroku_app" "foobar" {
name = "terraform-test-app"
region = "us"
config_vars {
FOO = "bar"
@ -239,6 +240,7 @@ resource "heroku_app" "foobar" {
const testAccCheckHerokuAppConfig_updated = `
resource "heroku_app" "foobar" {
name = "terraform-test-renamed"
region = "us"
config_vars {
FOO = "bing"
@ -249,4 +251,5 @@ resource "heroku_app" "foobar" {
const testAccCheckHerokuAppConfig_no_vars = `
resource "heroku_app" "foobar" {
name = "terraform-test-app"
region = "us"
}`

View File

@ -96,6 +96,7 @@ func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.Te
const testAccCheckHerokuDomainConfig_basic = `
resource "heroku_app" "foobar" {
name = "terraform-test-app"
region = "us"
}
resource "heroku_domain" "foobar" {

View File

@ -98,6 +98,7 @@ func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.Te
const testAccCheckHerokuDrainConfig_basic = `
resource "heroku_app" "foobar" {
name = "terraform-test-app"
region = "us"
}
resource "heroku_drain" "foobar" {

View File

@ -26,9 +26,9 @@ resource "heroku_app" "default" {
The following arguments are supported:
* `name` - (Optional) The name of the application. In Heroku, this is also the
unique ID.
* `region` - (Optional) The region that the app should be deployed in.
* `name` - (Required) The name of the application. In Heroku, this is also the
unique ID, so it must be unique and have a minimum of 3 characters.
* `region` - (Required) The region that the app should be deployed in.
* `stack` - (Optional) The application stack is what platform to run the application
in.
* `config_vars` - (Optional) Configuration variables for the application.