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:
parent
18cb0f09b9
commit
02d18d67b8
|
@ -2,6 +2,7 @@ package heroku
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cyberdelia/heroku-go/v3"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
|
@ -25,12 +26,15 @@ func (c *Config) Client() (*heroku.Service, error) {
|
||||||
c.APIKey = v
|
c.APIKey = v
|
||||||
}
|
}
|
||||||
|
|
||||||
heroku.DefaultTransport.Username = c.Email
|
service := heroku.NewService(&http.Client{
|
||||||
heroku.DefaultTransport.Password = c.APIKey
|
Transport: &heroku.Transport{
|
||||||
|
Username: c.Email,
|
||||||
client := heroku.NewService(heroku.DefaultClient)
|
Password: c.APIKey,
|
||||||
|
UserAgent: heroku.DefaultUserAgent,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
log.Printf("[INFO] Heroku Client configured for user: %s", c.Email)
|
log.Printf("[INFO] Heroku Client configured for user: %s", c.Email)
|
||||||
|
|
||||||
return client, nil
|
return service, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cyberdelia/heroku-go/v3"
|
|
||||||
"github.com/hashicorp/terraform/config"
|
"github.com/hashicorp/terraform/config"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
@ -61,13 +60,6 @@ func TestProviderConfigure(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
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) {
|
func testAccPreCheck(t *testing.T) {
|
||||||
|
|
|
@ -96,6 +96,7 @@ func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestC
|
||||||
const testAccCheckHerokuAddonConfig_basic = `
|
const testAccCheckHerokuAddonConfig_basic = `
|
||||||
resource "heroku_app" "foobar" {
|
resource "heroku_app" "foobar" {
|
||||||
name = "terraform-test-app"
|
name = "terraform-test-app"
|
||||||
|
region = "us"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "heroku_addon" "foobar" {
|
resource "heroku_addon" "foobar" {
|
||||||
|
|
|
@ -50,14 +50,13 @@ func resourceHerokuApp() *schema.Resource {
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Required: true,
|
||||||
Computed: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"region": &schema.Schema{
|
"region": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Required: true,
|
||||||
Computed: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"stack": &schema.Schema{
|
"stack": &schema.Schema{
|
||||||
|
|
|
@ -230,6 +230,7 @@ func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFu
|
||||||
const testAccCheckHerokuAppConfig_basic = `
|
const testAccCheckHerokuAppConfig_basic = `
|
||||||
resource "heroku_app" "foobar" {
|
resource "heroku_app" "foobar" {
|
||||||
name = "terraform-test-app"
|
name = "terraform-test-app"
|
||||||
|
region = "us"
|
||||||
|
|
||||||
config_vars {
|
config_vars {
|
||||||
FOO = "bar"
|
FOO = "bar"
|
||||||
|
@ -239,6 +240,7 @@ resource "heroku_app" "foobar" {
|
||||||
const testAccCheckHerokuAppConfig_updated = `
|
const testAccCheckHerokuAppConfig_updated = `
|
||||||
resource "heroku_app" "foobar" {
|
resource "heroku_app" "foobar" {
|
||||||
name = "terraform-test-renamed"
|
name = "terraform-test-renamed"
|
||||||
|
region = "us"
|
||||||
|
|
||||||
config_vars {
|
config_vars {
|
||||||
FOO = "bing"
|
FOO = "bing"
|
||||||
|
@ -249,4 +251,5 @@ resource "heroku_app" "foobar" {
|
||||||
const testAccCheckHerokuAppConfig_no_vars = `
|
const testAccCheckHerokuAppConfig_no_vars = `
|
||||||
resource "heroku_app" "foobar" {
|
resource "heroku_app" "foobar" {
|
||||||
name = "terraform-test-app"
|
name = "terraform-test-app"
|
||||||
|
region = "us"
|
||||||
}`
|
}`
|
||||||
|
|
|
@ -96,6 +96,7 @@ func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.Te
|
||||||
const testAccCheckHerokuDomainConfig_basic = `
|
const testAccCheckHerokuDomainConfig_basic = `
|
||||||
resource "heroku_app" "foobar" {
|
resource "heroku_app" "foobar" {
|
||||||
name = "terraform-test-app"
|
name = "terraform-test-app"
|
||||||
|
region = "us"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "heroku_domain" "foobar" {
|
resource "heroku_domain" "foobar" {
|
||||||
|
|
|
@ -98,6 +98,7 @@ func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.Te
|
||||||
const testAccCheckHerokuDrainConfig_basic = `
|
const testAccCheckHerokuDrainConfig_basic = `
|
||||||
resource "heroku_app" "foobar" {
|
resource "heroku_app" "foobar" {
|
||||||
name = "terraform-test-app"
|
name = "terraform-test-app"
|
||||||
|
region = "us"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "heroku_drain" "foobar" {
|
resource "heroku_drain" "foobar" {
|
||||||
|
|
|
@ -26,9 +26,9 @@ resource "heroku_app" "default" {
|
||||||
|
|
||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
* `name` - (Optional) The name of the application. In Heroku, this is also the
|
* `name` - (Required) The name of the application. In Heroku, this is also the
|
||||||
unique ID.
|
unique ID, so it must be unique and have a minimum of 3 characters.
|
||||||
* `region` - (Optional) The region that the app should be deployed in.
|
* `region` - (Required) The region that the app should be deployed in.
|
||||||
* `stack` - (Optional) The application stack is what platform to run the application
|
* `stack` - (Optional) The application stack is what platform to run the application
|
||||||
in.
|
in.
|
||||||
* `config_vars` - (Optional) Configuration variables for the application.
|
* `config_vars` - (Optional) Configuration variables for the application.
|
||||||
|
|
Loading…
Reference in New Issue