Merge pull request #239 from catsby/heroku-go-update
Swap bgentry/heroku-go for cyberdelia/heroku-go
This commit is contained in:
commit
9842577723
|
@ -4,7 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -12,9 +12,9 @@ type Config struct {
|
||||||
Email string `mapstructure:"email"`
|
Email string `mapstructure:"email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client() returns a new client for accessing heroku.
|
// Client() returns a new Service for accessing Heroku.
|
||||||
//
|
//
|
||||||
func (c *Config) Client() (*heroku.Client, error) {
|
func (c *Config) Client() (*heroku.Service, error) {
|
||||||
|
|
||||||
// If we have env vars set (like in the acc) tests,
|
// If we have env vars set (like in the acc) tests,
|
||||||
// we need to override the values passed in here.
|
// we need to override the values passed in here.
|
||||||
|
@ -25,9 +25,12 @@ func (c *Config) Client() (*heroku.Client, error) {
|
||||||
c.APIKey = v
|
c.APIKey = v
|
||||||
}
|
}
|
||||||
|
|
||||||
client := heroku.Client{Username: c.Email, Password: c.APIKey}
|
heroku.DefaultTransport.Username = c.Email
|
||||||
|
heroku.DefaultTransport.Password = c.APIKey
|
||||||
|
|
||||||
|
client := heroku.NewService(heroku.DefaultClient)
|
||||||
|
|
||||||
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 client, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"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"
|
||||||
|
@ -62,12 +62,11 @@ func TestProviderConfigure(t *testing.T) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := rp.Meta().(*heroku.Client)
|
if heroku.DefaultTransport.Username != expectedEmail {
|
||||||
if config.Username != expectedEmail {
|
t.Fatalf("bad: %#v", heroku.DefaultTransport)
|
||||||
t.Fatalf("bad: %#v", config)
|
|
||||||
}
|
}
|
||||||
if config.Password != expectedKey {
|
if heroku.DefaultTransport.Password != expectedKey {
|
||||||
t.Fatalf("bad: %#v", config)
|
t.Fatalf("bad: %#v", heroku.DefaultTransport)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -61,11 +61,10 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
addonLock.Lock()
|
addonLock.Lock()
|
||||||
defer addonLock.Unlock()
|
defer addonLock.Unlock()
|
||||||
|
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
app := d.Get("app").(string)
|
app := d.Get("app").(string)
|
||||||
plan := d.Get("plan").(string)
|
opts := heroku.AddonCreateOpts{Plan: d.Get("plan").(string)}
|
||||||
opts := heroku.AddonCreateOpts{}
|
|
||||||
|
|
||||||
if v := d.Get("config"); v != nil {
|
if v := d.Get("config"); v != nil {
|
||||||
config := make(map[string]string)
|
config := make(map[string]string)
|
||||||
|
@ -78,20 +77,20 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
opts.Config = &config
|
opts.Config = &config
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Addon create configuration: %#v, %#v, %#v", app, plan, opts)
|
log.Printf("[DEBUG] Addon create configuration: %#v, %#v", app, opts)
|
||||||
a, err := client.AddonCreate(app, plan, &opts)
|
a, err := client.AddonCreate(app, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(a.Id)
|
d.SetId(a.ID)
|
||||||
log.Printf("[INFO] Addon ID: %s", d.Id())
|
log.Printf("[INFO] Addon ID: %s", d.Id())
|
||||||
|
|
||||||
return resourceHerokuAddonRead(d, meta)
|
return resourceHerokuAddonRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
addon, err := resource_heroku_addon_retrieve(
|
addon, err := resource_heroku_addon_retrieve(
|
||||||
d.Get("app").(string), d.Id(), client)
|
d.Get("app").(string), d.Id(), client)
|
||||||
|
@ -101,7 +100,7 @@ func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
d.Set("name", addon.Name)
|
d.Set("name", addon.Name)
|
||||||
d.Set("plan", addon.Plan.Name)
|
d.Set("plan", addon.Plan.Name)
|
||||||
d.Set("provider_id", addon.ProviderId)
|
d.Set("provider_id", addon.ProviderID)
|
||||||
d.Set("config_vars", []interface{}{addon.ConfigVars})
|
d.Set("config_vars", []interface{}{addon.ConfigVars})
|
||||||
d.SetDependencies([]terraform.ResourceDependency{
|
d.SetDependencies([]terraform.ResourceDependency{
|
||||||
terraform.ResourceDependency{ID: d.Get("app").(string)},
|
terraform.ResourceDependency{ID: d.Get("app").(string)},
|
||||||
|
@ -111,26 +110,26 @@ func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAddonUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAddonUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
app := d.Get("app").(string)
|
app := d.Get("app").(string)
|
||||||
|
|
||||||
if d.HasChange("plan") {
|
if d.HasChange("plan") {
|
||||||
ad, err := client.AddonUpdate(
|
ad, err := client.AddonUpdate(
|
||||||
app, d.Id(), d.Get("plan").(string))
|
app, d.Id(), heroku.AddonUpdateOpts{Plan: d.Get("plan").(string)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the new ID
|
// Store the new ID
|
||||||
d.SetId(ad.Id)
|
d.SetId(ad.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceHerokuAddonRead(d, meta)
|
return resourceHerokuAddonRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting Addon: %s", d.Id())
|
log.Printf("[INFO] Deleting Addon: %s", d.Id())
|
||||||
|
|
||||||
|
@ -144,7 +143,7 @@ func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_heroku_addon_retrieve(app string, id string, client *heroku.Client) (*heroku.Addon, error) {
|
func resource_heroku_addon_retrieve(app string, id string, client *heroku.Service) (*heroku.Addon, error) {
|
||||||
addon, err := client.AddonInfo(app, id)
|
addon, err := client.AddonInfo(app, id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -35,7 +35,7 @@ func TestAccHerokuAddon_Basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
|
func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.Resources {
|
||||||
if rs.Type != "heroku_addon" {
|
if rs.Type != "heroku_addon" {
|
||||||
|
@ -75,7 +75,7 @@ func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestC
|
||||||
return fmt.Errorf("No Addon ID is set")
|
return fmt.Errorf("No Addon ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
foundAddon, err := client.AddonInfo(rs.Attributes["app"], rs.ID)
|
foundAddon, err := client.AddonInfo(rs.Attributes["app"], rs.ID)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestC
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundAddon.Id != rs.ID {
|
if foundAddon.ID != rs.ID {
|
||||||
return fmt.Errorf("Addon not found")
|
return fmt.Errorf("Addon not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/multierror"
|
"github.com/hashicorp/terraform/helper/multierror"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,7 @@ type application struct {
|
||||||
Id string // Id of the resource
|
Id string // Id of the resource
|
||||||
|
|
||||||
App *heroku.App // The heroku application
|
App *heroku.App // The heroku application
|
||||||
Client *heroku.Client // Client to interact with the heroku API
|
Client *heroku.Service // Client to interact with the heroku API
|
||||||
Vars map[string]string // The vars on the application
|
Vars map[string]string // The vars on the application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func resourceHerokuApp() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
// Build up our creation options
|
// Build up our creation options
|
||||||
opts := heroku.AppCreateOpts{}
|
opts := heroku.AppCreateOpts{}
|
||||||
|
@ -117,7 +117,7 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Creating Heroku app...")
|
log.Printf("[DEBUG] Creating Heroku app...")
|
||||||
a, err := client.AppCreate(&opts)
|
a, err := client.AppCreate(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
app, err := resource_heroku_app_retrieve(d.Id(), client)
|
app, err := resource_heroku_app_retrieve(d.Id(), client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -157,7 +157,7 @@ func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
// If name changed, update it
|
// If name changed, update it
|
||||||
if d.HasChange("name") {
|
if d.HasChange("name") {
|
||||||
|
@ -166,7 +166,7 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
Name: &v,
|
Name: &v,
|
||||||
}
|
}
|
||||||
|
|
||||||
renamedApp, err := client.AppUpdate(d.Id(), &opts)
|
renamedApp, err := client.AppUpdate(d.Id(), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting App: %s", d.Id())
|
log.Printf("[INFO] Deleting App: %s", d.Id())
|
||||||
err := client.AppDelete(d.Id())
|
err := client.AppDelete(d.Id())
|
||||||
|
@ -208,7 +208,7 @@ func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_heroku_app_retrieve(id string, client *heroku.Client) (*application, error) {
|
func resource_heroku_app_retrieve(id string, client *heroku.Service) (*application, error) {
|
||||||
app := application{Id: id, Client: client}
|
app := application{Id: id, Client: client}
|
||||||
|
|
||||||
err := app.Update()
|
err := app.Update()
|
||||||
|
@ -220,7 +220,7 @@ func resource_heroku_app_retrieve(id string, client *heroku.Client) (*applicatio
|
||||||
return &app, nil
|
return &app, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func retrieve_config_vars(id string, client *heroku.Client) (map[string]string, error) {
|
func retrieve_config_vars(id string, client *heroku.Service) (map[string]string, error) {
|
||||||
vars, err := client.ConfigVarInfo(id)
|
vars, err := client.ConfigVarInfo(id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -233,7 +233,7 @@ func retrieve_config_vars(id string, client *heroku.Client) (map[string]string,
|
||||||
// Updates the config vars for from an expanded configuration.
|
// Updates the config vars for from an expanded configuration.
|
||||||
func update_config_vars(
|
func update_config_vars(
|
||||||
id string,
|
id string,
|
||||||
client *heroku.Client,
|
client *heroku.Service,
|
||||||
o []interface{},
|
o []interface{},
|
||||||
n []interface{}) error {
|
n []interface{}) error {
|
||||||
vars := make(map[string]*string)
|
vars := make(map[string]*string)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -103,7 +103,7 @@ func TestAccHerokuApp_NukeVars(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckHerokuAppDestroy(s *terraform.State) error {
|
func testAccCheckHerokuAppDestroy(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.Resources {
|
||||||
if rs.Type != "heroku_app" {
|
if rs.Type != "heroku_app" {
|
||||||
|
@ -122,7 +122,7 @@ func testAccCheckHerokuAppDestroy(s *terraform.State) error {
|
||||||
|
|
||||||
func testAccCheckHerokuAppAttributes(app *heroku.App) resource.TestCheckFunc {
|
func testAccCheckHerokuAppAttributes(app *heroku.App) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
if app.Region.Name != "us" {
|
if app.Region.Name != "us" {
|
||||||
return fmt.Errorf("Bad region: %s", app.Region.Name)
|
return fmt.Errorf("Bad region: %s", app.Region.Name)
|
||||||
|
@ -151,7 +151,7 @@ func testAccCheckHerokuAppAttributes(app *heroku.App) resource.TestCheckFunc {
|
||||||
|
|
||||||
func testAccCheckHerokuAppAttributesUpdated(app *heroku.App) resource.TestCheckFunc {
|
func testAccCheckHerokuAppAttributesUpdated(app *heroku.App) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
if app.Name != "terraform-test-renamed" {
|
if app.Name != "terraform-test-renamed" {
|
||||||
return fmt.Errorf("Bad name: %s", app.Name)
|
return fmt.Errorf("Bad name: %s", app.Name)
|
||||||
|
@ -178,7 +178,7 @@ func testAccCheckHerokuAppAttributesUpdated(app *heroku.App) resource.TestCheckF
|
||||||
|
|
||||||
func testAccCheckHerokuAppAttributesNoVars(app *heroku.App) resource.TestCheckFunc {
|
func testAccCheckHerokuAppAttributesNoVars(app *heroku.App) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
if app.Name != "terraform-test-app" {
|
if app.Name != "terraform-test-app" {
|
||||||
return fmt.Errorf("Bad name: %s", app.Name)
|
return fmt.Errorf("Bad name: %s", app.Name)
|
||||||
|
@ -209,7 +209,7 @@ func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFu
|
||||||
return fmt.Errorf("No App Name is set")
|
return fmt.Errorf("No App Name is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
foundApp, err := client.AppInfo(rs.ID)
|
foundApp, err := client.AppInfo(rs.ID)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -37,19 +37,19 @@ func resourceHerokuDomain() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
app := d.Get("app").(string)
|
app := d.Get("app").(string)
|
||||||
hostname := d.Get("hostname").(string)
|
hostname := d.Get("hostname").(string)
|
||||||
|
|
||||||
log.Printf("[DEBUG] Domain create configuration: %#v, %#v", app, hostname)
|
log.Printf("[DEBUG] Domain create configuration: %#v, %#v", app, hostname)
|
||||||
|
|
||||||
do, err := client.DomainCreate(app, hostname)
|
do, err := client.DomainCreate(app, heroku.DomainCreateOpts{hostname})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(do.Id)
|
d.SetId(do.ID)
|
||||||
d.Set("hostname", do.Hostname)
|
d.Set("hostname", do.Hostname)
|
||||||
d.Set("cname", fmt.Sprintf("%s.herokuapp.com", app))
|
d.Set("cname", fmt.Sprintf("%s.herokuapp.com", app))
|
||||||
d.SetDependencies([]terraform.ResourceDependency{
|
d.SetDependencies([]terraform.ResourceDependency{
|
||||||
|
@ -61,7 +61,7 @@ func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuDomainDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuDomainDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting Domain: %s", d.Id())
|
log.Printf("[INFO] Deleting Domain: %s", d.Id())
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ func resourceHerokuDomainDelete(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuDomainRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
app := d.Get("app").(string)
|
app := d.Get("app").(string)
|
||||||
do, err := client.DomainInfo(app, d.Id())
|
do, err := client.DomainInfo(app, d.Id())
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -35,7 +35,7 @@ func TestAccHerokuDomain_Basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckHerokuDomainDestroy(s *terraform.State) error {
|
func testAccCheckHerokuDomainDestroy(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.Resources {
|
||||||
if rs.Type != "heroku_domain" {
|
if rs.Type != "heroku_domain" {
|
||||||
|
@ -75,7 +75,7 @@ func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.Te
|
||||||
return fmt.Errorf("No Domain ID is set")
|
return fmt.Errorf("No Domain ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
foundDomain, err := client.DomainInfo(rs.Attributes["app"], rs.ID)
|
foundDomain, err := client.DomainInfo(rs.Attributes["app"], rs.ID)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.Te
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundDomain.Id != rs.ID {
|
if foundDomain.ID != rs.ID {
|
||||||
return fmt.Errorf("Domain not found")
|
return fmt.Errorf("Domain not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -37,19 +37,19 @@ func resourceHerokuDrain() *schema.Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuDrainCreate(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuDrainCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
app := d.Get("app").(string)
|
app := d.Get("app").(string)
|
||||||
url := d.Get("url").(string)
|
url := d.Get("url").(string)
|
||||||
|
|
||||||
log.Printf("[DEBUG] Drain create configuration: %#v, %#v", app, url)
|
log.Printf("[DEBUG] Drain create configuration: %#v, %#v", app, url)
|
||||||
|
|
||||||
dr, err := client.LogDrainCreate(app, url)
|
dr, err := client.LogDrainCreate(app, heroku.LogDrainCreateOpts{url})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(dr.Id)
|
d.SetId(dr.ID)
|
||||||
d.Set("url", dr.URL)
|
d.Set("url", dr.URL)
|
||||||
d.Set("token", dr.Token)
|
d.Set("token", dr.Token)
|
||||||
d.SetDependencies([]terraform.ResourceDependency{
|
d.SetDependencies([]terraform.ResourceDependency{
|
||||||
|
@ -61,7 +61,7 @@ func resourceHerokuDrainCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuDrainDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuDrainDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting drain: %s", d.Id())
|
log.Printf("[INFO] Deleting drain: %s", d.Id())
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ func resourceHerokuDrainDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceHerokuDrainRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceHerokuDrainRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Client)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
dr, err := client.LogDrainInfo(d.Get("app").(string), d.Id())
|
dr, err := client.LogDrainInfo(d.Get("app").(string), d.Id())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bgentry/heroku-go"
|
"github.com/cyberdelia/heroku-go/v3"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -33,7 +33,7 @@ func TestAccHerokuDrain_Basic(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccCheckHerokuDrainDestroy(s *terraform.State) error {
|
func testAccCheckHerokuDrainDestroy(s *terraform.State) error {
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
for _, rs := range s.Resources {
|
for _, rs := range s.Resources {
|
||||||
if rs.Type != "heroku_drain" {
|
if rs.Type != "heroku_drain" {
|
||||||
|
@ -77,7 +77,7 @@ func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.Te
|
||||||
return fmt.Errorf("No Drain ID is set")
|
return fmt.Errorf("No Drain ID is set")
|
||||||
}
|
}
|
||||||
|
|
||||||
client := testAccProvider.Meta().(*heroku.Client)
|
client := testAccProvider.Meta().(*heroku.Service)
|
||||||
|
|
||||||
foundDrain, err := client.LogDrainInfo(rs.Attributes["app"], rs.ID)
|
foundDrain, err := client.LogDrainInfo(rs.Attributes["app"], rs.ID)
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.Te
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundDrain.Id != rs.ID {
|
if foundDrain.ID != rs.ID {
|
||||||
return fmt.Errorf("Drain not found")
|
return fmt.Errorf("Drain not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue