Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap bgentry/heroku-go for cyberdelia/heroku-go #239

Merged
merged 1 commit into from
Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions builtin/providers/heroku/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"log"
"os"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
)

type Config struct {
APIKey string `mapstructure:"api_key"`
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,
// we need to override the values passed in here.
Expand All @@ -25,9 +25,12 @@ func (c *Config) Client() (*heroku.Client, error) {
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)

return &client, nil
return client, nil
}
11 changes: 5 additions & 6 deletions builtin/providers/heroku/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"testing"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
Expand Down Expand Up @@ -62,12 +62,11 @@ func TestProviderConfigure(t *testing.T) {
t.Fatalf("err: %s", err)
}

config := rp.Meta().(*heroku.Client)
if config.Username != expectedEmail {
t.Fatalf("bad: %#v", config)
if heroku.DefaultTransport.Username != expectedEmail {
t.Fatalf("bad: %#v", heroku.DefaultTransport)
}
if config.Password != expectedKey {
t.Fatalf("bad: %#v", config)
if heroku.DefaultTransport.Password != expectedKey {
t.Fatalf("bad: %#v", heroku.DefaultTransport)
}
}

Expand Down
27 changes: 13 additions & 14 deletions builtin/providers/heroku/resource_heroku_addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"sync"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -61,11 +61,10 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
addonLock.Lock()
defer addonLock.Unlock()

client := meta.(*heroku.Client)
client := meta.(*heroku.Service)

app := d.Get("app").(string)
plan := d.Get("plan").(string)
opts := heroku.AddonCreateOpts{}
opts := heroku.AddonCreateOpts{Plan: d.Get("plan").(string)}

if v := d.Get("config"); v != nil {
config := make(map[string]string)
Expand All @@ -78,20 +77,20 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
opts.Config = &config
}

log.Printf("[DEBUG] Addon create configuration: %#v, %#v, %#v", app, plan, opts)
a, err := client.AddonCreate(app, plan, &opts)
log.Printf("[DEBUG] Addon create configuration: %#v, %#v", app, opts)
a, err := client.AddonCreate(app, opts)
if err != nil {
return err
}

d.SetId(a.Id)
d.SetId(a.ID)
log.Printf("[INFO] Addon ID: %s", d.Id())

return resourceHerokuAddonRead(d, meta)
}

func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Client)
client := meta.(*heroku.Service)

addon, err := resource_heroku_addon_retrieve(
d.Get("app").(string), d.Id(), client)
Expand All @@ -101,7 +100,7 @@ func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {

d.Set("name", addon.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.SetDependencies([]terraform.ResourceDependency{
terraform.ResourceDependency{ID: d.Get("app").(string)},
Expand All @@ -111,26 +110,26 @@ func resourceHerokuAddonRead(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)

if d.HasChange("plan") {
ad, err := client.AddonUpdate(
app, d.Id(), d.Get("plan").(string))
app, d.Id(), heroku.AddonUpdateOpts{Plan: d.Get("plan").(string)})
if err != nil {
return err
}

// Store the new ID
d.SetId(ad.Id)
d.SetId(ad.ID)
}

return resourceHerokuAddonRead(d, meta)
}

func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Client)
client := meta.(*heroku.Service)

log.Printf("[INFO] Deleting Addon: %s", d.Id())

Expand All @@ -144,7 +143,7 @@ func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
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)

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions builtin/providers/heroku/resource_heroku_addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -35,7 +35,7 @@ func TestAccHerokuAddon_Basic(t *testing.T) {
}

func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Client)
client := testAccProvider.Meta().(*heroku.Service)

for _, rs := range s.Resources {
if rs.Type != "heroku_addon" {
Expand Down Expand Up @@ -75,15 +75,15 @@ func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestC
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)

if err != nil {
return err
}

if foundAddon.Id != rs.ID {
if foundAddon.ID != rs.ID {
return fmt.Errorf("Addon not found")
}

Expand Down
22 changes: 11 additions & 11 deletions builtin/providers/heroku/resource_heroku_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/multierror"
"github.com/hashicorp/terraform/helper/schema"
)
Expand All @@ -14,7 +14,7 @@ type application struct {
Id string // Id of the resource

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
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func resourceHerokuApp() *schema.Resource {
}

func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Client)
client := meta.(*heroku.Service)

// Build up our creation options
opts := heroku.AppCreateOpts{}
Expand All @@ -117,7 +117,7 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
}

log.Printf("[DEBUG] Creating Heroku app...")
a, err := client.AppCreate(&opts)
a, err := client.AppCreate(opts)
if err != nil {
return err
}
Expand All @@ -136,7 +136,7 @@ func resourceHerokuAppCreate(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)
if err != nil {
return err
Expand All @@ -157,7 +157,7 @@ func resourceHerokuAppRead(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 d.HasChange("name") {
Expand All @@ -166,7 +166,7 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
Name: &v,
}

renamedApp, err := client.AppUpdate(d.Id(), &opts)
renamedApp, err := client.AppUpdate(d.Id(), opts)
if err != nil {
return err
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func resourceHerokuAppUpdate(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())
err := client.AppDelete(d.Id())
Expand All @@ -208,7 +208,7 @@ func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
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}

err := app.Update()
Expand All @@ -220,7 +220,7 @@ func resource_heroku_app_retrieve(id string, client *heroku.Client) (*applicatio
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)

if err != nil {
Expand All @@ -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.
func update_config_vars(
id string,
client *heroku.Client,
client *heroku.Service,
o []interface{},
n []interface{}) error {
vars := make(map[string]*string)
Expand Down
12 changes: 6 additions & 6 deletions builtin/providers/heroku/resource_heroku_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestAccHerokuApp_NukeVars(t *testing.T) {
}

func testAccCheckHerokuAppDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Client)
client := testAccProvider.Meta().(*heroku.Service)

for _, rs := range s.Resources {
if rs.Type != "heroku_app" {
Expand All @@ -122,7 +122,7 @@ func testAccCheckHerokuAppDestroy(s *terraform.State) error {

func testAccCheckHerokuAppAttributes(app *heroku.App) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Client)
client := testAccProvider.Meta().(*heroku.Service)

if app.Region.Name != "us" {
return fmt.Errorf("Bad region: %s", app.Region.Name)
Expand Down Expand Up @@ -151,7 +151,7 @@ func testAccCheckHerokuAppAttributes(app *heroku.App) resource.TestCheckFunc {

func testAccCheckHerokuAppAttributesUpdated(app *heroku.App) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Client)
client := testAccProvider.Meta().(*heroku.Service)

if app.Name != "terraform-test-renamed" {
return fmt.Errorf("Bad name: %s", app.Name)
Expand All @@ -178,7 +178,7 @@ func testAccCheckHerokuAppAttributesUpdated(app *heroku.App) resource.TestCheckF

func testAccCheckHerokuAppAttributesNoVars(app *heroku.App) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Client)
client := testAccProvider.Meta().(*heroku.Service)

if app.Name != "terraform-test-app" {
return fmt.Errorf("Bad name: %s", app.Name)
Expand Down Expand Up @@ -209,7 +209,7 @@ func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFu
return fmt.Errorf("No App Name is set")
}

client := testAccProvider.Meta().(*heroku.Client)
client := testAccProvider.Meta().(*heroku.Service)

foundApp, err := client.AppInfo(rs.ID)

Expand Down
12 changes: 6 additions & 6 deletions builtin/providers/heroku/resource_heroku_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/bgentry/heroku-go"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -37,19 +37,19 @@ func resourceHerokuDomain() *schema.Resource {
}

func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Client)
client := meta.(*heroku.Service)

app := d.Get("app").(string)
hostname := d.Get("hostname").(string)

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 {
return err
}

d.SetId(do.Id)
d.SetId(do.ID)
d.Set("hostname", do.Hostname)
d.Set("cname", fmt.Sprintf("%s.herokuapp.com", app))
d.SetDependencies([]terraform.ResourceDependency{
Expand All @@ -61,7 +61,7 @@ func resourceHerokuDomainCreate(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())

Expand All @@ -75,7 +75,7 @@ func resourceHerokuDomainDelete(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)
do, err := client.DomainInfo(app, d.Id())
Expand Down
Loading