Updates heroku-go to the latest revision (#12575)

This commit is contained in:
Andy Lindeman 2017-03-10 07:00:03 -05:00 committed by Paul Stack
parent 2a136ef09b
commit fa18174713
13 changed files with 12411 additions and 1257 deletions

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"log"
"strings"
@ -23,18 +24,18 @@ func resourceHerokuAddon() *schema.Resource {
Delete: resourceHerokuAddonDelete,
Schema: map[string]*schema.Schema{
"app": &schema.Schema{
"app": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"plan": &schema.Schema{
"plan": {
Type: schema.TypeString,
Required: true,
},
"config": &schema.Schema{
"config": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
@ -43,12 +44,12 @@ func resourceHerokuAddon() *schema.Resource {
},
},
"provider_id": &schema.Schema{
"provider_id": {
Type: schema.TypeString,
Computed: true,
},
"config_vars": &schema.Schema{
"config_vars": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
@ -66,7 +67,7 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Service)
app := d.Get("app").(string)
opts := heroku.AddonCreateOpts{Plan: d.Get("plan").(string)}
opts := heroku.AddOnCreateOpts{Plan: d.Get("plan").(string)}
if v := d.Get("config"); v != nil {
config := make(map[string]string)
@ -80,7 +81,7 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
}
log.Printf("[DEBUG] Addon create configuration: %#v, %#v", app, opts)
a, err := client.AddonCreate(app, opts)
a, err := client.AddOnCreate(context.TODO(), app, opts)
if err != nil {
return err
}
@ -129,8 +130,8 @@ func resourceHerokuAddonUpdate(d *schema.ResourceData, meta interface{}) error {
app := d.Get("app").(string)
if d.HasChange("plan") {
ad, err := client.AddonUpdate(
app, d.Id(), heroku.AddonUpdateOpts{Plan: d.Get("plan").(string)})
ad, err := client.AddOnUpdate(
context.TODO(), app, d.Id(), heroku.AddOnUpdateOpts{Plan: d.Get("plan").(string)})
if err != nil {
return err
}
@ -148,7 +149,7 @@ func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting Addon: %s", d.Id())
// Destroy the app
err := client.AddonDelete(d.Get("app").(string), d.Id())
_, err := client.AddOnDelete(context.TODO(), d.Get("app").(string), d.Id())
if err != nil {
return fmt.Errorf("Error deleting addon: %s", err)
}
@ -157,8 +158,8 @@ func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceHerokuAddonRetrieve(app string, id string, client *heroku.Service) (*heroku.Addon, error) {
addon, err := client.AddonInfo(app, id)
func resourceHerokuAddonRetrieve(app string, id string, client *heroku.Service) (*heroku.AddOnInfoResult, error) {
addon, err := client.AddOnInfo(context.TODO(), app, id)
if err != nil {
return nil, fmt.Errorf("Error retrieving addon: %s", err)

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"testing"
@ -11,7 +12,7 @@ import (
)
func TestAccHerokuAddon_Basic(t *testing.T) {
var addon heroku.Addon
var addon heroku.AddOnInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
@ -19,7 +20,7 @@ func TestAccHerokuAddon_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAddonDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuAddonConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAddonExists("heroku_addon.foobar", &addon),
@ -38,7 +39,7 @@ func TestAccHerokuAddon_Basic(t *testing.T) {
// GH-198
func TestAccHerokuAddon_noPlan(t *testing.T) {
var addon heroku.Addon
var addon heroku.AddOnInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
@ -46,7 +47,7 @@ func TestAccHerokuAddon_noPlan(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAddonDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuAddonConfig_no_plan(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAddonExists("heroku_addon.foobar", &addon),
@ -57,7 +58,7 @@ func TestAccHerokuAddon_noPlan(t *testing.T) {
"heroku_addon.foobar", "plan", "memcachier"),
),
},
resource.TestStep{
{
Config: testAccCheckHerokuAddonConfig_no_plan(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAddonExists("heroku_addon.foobar", &addon),
@ -80,7 +81,7 @@ func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
continue
}
_, err := client.AddonInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
_, err := client.AddOnInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil {
return fmt.Errorf("Addon still exists")
@ -90,7 +91,7 @@ func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
return nil
}
func testAccCheckHerokuAddonAttributes(addon *heroku.Addon, n string) resource.TestCheckFunc {
func testAccCheckHerokuAddonAttributes(addon *heroku.AddOnInfoResult, n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if addon.Plan.Name != n {
@ -101,7 +102,7 @@ func testAccCheckHerokuAddonAttributes(addon *heroku.Addon, n string) resource.T
}
}
func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestCheckFunc {
func testAccCheckHerokuAddonExists(n string, addon *heroku.AddOnInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
@ -115,7 +116,7 @@ func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestC
client := testAccProvider.Meta().(*heroku.Service)
foundAddon, err := client.AddonInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
foundAddon, err := client.AddOnInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err != nil {
return err

View File

@ -1,11 +1,12 @@
package heroku
import (
"context"
"fmt"
"log"
"github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/go-multierror"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform/helper/schema"
)
@ -38,7 +39,7 @@ func (a *application) Update() error {
var err error
if !a.Organization {
app, err := a.Client.AppInfo(a.Id)
app, err := a.Client.AppInfo(context.TODO(), a.Id)
if err != nil {
errs = append(errs, err)
} else {
@ -50,7 +51,7 @@ func (a *application) Update() error {
a.App.WebURL = app.WebURL
}
} else {
app, err := a.Client.OrganizationAppInfo(a.Id)
app, err := a.Client.OrganizationAppInfo(context.TODO(), a.Id)
if err != nil {
errs = append(errs, err)
} else {
@ -90,25 +91,25 @@ func resourceHerokuApp() *schema.Resource {
Delete: resourceHerokuAppDelete,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"region": &schema.Schema{
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"stack": &schema.Schema{
"stack": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"config_vars": &schema.Schema{
"config_vars": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
@ -116,43 +117,43 @@ func resourceHerokuApp() *schema.Resource {
},
},
"all_config_vars": &schema.Schema{
"all_config_vars": {
Type: schema.TypeMap,
Computed: true,
},
"git_url": &schema.Schema{
"git_url": {
Type: schema.TypeString,
Computed: true,
},
"web_url": &schema.Schema{
"web_url": {
Type: schema.TypeString,
Computed: true,
},
"heroku_hostname": &schema.Schema{
"heroku_hostname": {
Type: schema.TypeString,
Computed: true,
},
"organization": &schema.Schema{
"organization": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"locked": &schema.Schema{
"locked": {
Type: schema.TypeBool,
Optional: true,
},
"personal": &schema.Schema{
"personal": {
Type: schema.TypeBool,
Optional: true,
},
@ -199,7 +200,7 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
}
log.Printf("[DEBUG] Creating Heroku app...")
a, err := client.AppCreate(opts)
a, err := client.AppCreate(context.TODO(), opts)
if err != nil {
return err
}
@ -263,7 +264,7 @@ func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error
}
log.Printf("[DEBUG] Creating Heroku app...")
a, err := client.OrganizationAppCreate(opts)
a, err := client.OrganizationAppCreate(context.TODO(), opts)
if err != nil {
return err
}
@ -287,7 +288,7 @@ func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
configVars := make(map[string]string)
care := make(map[string]struct{})
for _, v := range d.Get("config_vars").([]interface{}) {
for k, _ := range v.(map[string]interface{}) {
for k := range v.(map[string]interface{}) {
care[k] = struct{}{}
}
}
@ -347,7 +348,7 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
Name: &v,
}
renamedApp, err := client.AppUpdate(d.Id(), opts)
renamedApp, err := client.AppUpdate(context.TODO(), d.Id(), opts)
if err != nil {
return err
}
@ -380,7 +381,7 @@ func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Service)
log.Printf("[INFO] Deleting App: %s", d.Id())
err := client.AppDelete(d.Id())
_, err := client.AppDelete(context.TODO(), d.Id())
if err != nil {
return fmt.Errorf("Error deleting App: %s", err)
}
@ -402,13 +403,20 @@ func resourceHerokuAppRetrieve(id string, organization bool, client *heroku.Serv
}
func retrieveConfigVars(id string, client *heroku.Service) (map[string]string, error) {
vars, err := client.ConfigVarInfo(id)
vars, err := client.ConfigVarInfoForApp(context.TODO(), id)
if err != nil {
return nil, err
}
return vars, nil
nonNullVars := map[string]string{}
for k, v := range vars {
if v != nil {
nonNullVars[k] = *v
}
}
return nonNullVars, nil
}
// Updates the config vars for from an expanded configuration.
@ -421,7 +429,7 @@ func updateConfigVars(
for _, v := range o {
if v != nil {
for k, _ := range v.(map[string]interface{}) {
for k := range v.(map[string]interface{}) {
vars[k] = nil
}
}
@ -436,7 +444,7 @@ func updateConfigVars(
}
log.Printf("[INFO] Updating config vars: *%#v", vars)
if _, err := client.ConfigVarUpdate(id, vars); err != nil {
if _, err := client.ConfigVarUpdate(context.TODO(), id, vars); err != nil {
return fmt.Errorf("Error updating config vars: %s", err)
}

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"os"
"testing"
@ -12,7 +13,7 @@ import (
)
func TestAccHerokuApp_Basic(t *testing.T) {
var app heroku.App
var app heroku.AppInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
@ -20,7 +21,7 @@ func TestAccHerokuApp_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAppDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuAppConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
@ -36,7 +37,7 @@ func TestAccHerokuApp_Basic(t *testing.T) {
}
func TestAccHerokuApp_NameChange(t *testing.T) {
var app heroku.App
var app heroku.AppInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
appName2 := fmt.Sprintf("%s-v2", appName)
@ -45,7 +46,7 @@ func TestAccHerokuApp_NameChange(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAppDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuAppConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
@ -56,7 +57,7 @@ func TestAccHerokuApp_NameChange(t *testing.T) {
"heroku_app.foobar", "config_vars.0.FOO", "bar"),
),
},
resource.TestStep{
{
Config: testAccCheckHerokuAppConfig_updated(appName2),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
@ -74,7 +75,7 @@ func TestAccHerokuApp_NameChange(t *testing.T) {
}
func TestAccHerokuApp_NukeVars(t *testing.T) {
var app heroku.App
var app heroku.AppInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
@ -82,7 +83,7 @@ func TestAccHerokuApp_NukeVars(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAppDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuAppConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
@ -93,7 +94,7 @@ func TestAccHerokuApp_NukeVars(t *testing.T) {
"heroku_app.foobar", "config_vars.0.FOO", "bar"),
),
},
resource.TestStep{
{
Config: testAccCheckHerokuAppConfig_no_vars(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
@ -123,7 +124,7 @@ func TestAccHerokuApp_Organization(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAppDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuAppConfig_organization(appName, org),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExistsOrg("heroku_app.foobar", &app),
@ -142,7 +143,7 @@ func testAccCheckHerokuAppDestroy(s *terraform.State) error {
continue
}
_, err := client.AppInfo(rs.Primary.ID)
_, err := client.AppInfo(context.TODO(), rs.Primary.ID)
if err == nil {
return fmt.Errorf("App still exists")
@ -152,7 +153,7 @@ func testAccCheckHerokuAppDestroy(s *terraform.State) error {
return nil
}
func testAccCheckHerokuAppAttributes(app *heroku.App, appName string) resource.TestCheckFunc {
func testAccCheckHerokuAppAttributes(app *heroku.AppInfoResult, appName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service)
@ -168,12 +169,12 @@ func testAccCheckHerokuAppAttributes(app *heroku.App, appName string) resource.T
return fmt.Errorf("Bad name: %s", app.Name)
}
vars, err := client.ConfigVarInfo(app.Name)
vars, err := client.ConfigVarInfoForApp(context.TODO(), app.Name)
if err != nil {
return err
}
if vars["FOO"] != "bar" {
if vars["FOO"] == nil || *vars["FOO"] != "bar" {
return fmt.Errorf("Bad config vars: %v", vars)
}
@ -181,7 +182,7 @@ func testAccCheckHerokuAppAttributes(app *heroku.App, appName string) resource.T
}
}
func testAccCheckHerokuAppAttributesUpdated(app *heroku.App, appName string) resource.TestCheckFunc {
func testAccCheckHerokuAppAttributesUpdated(app *heroku.AppInfoResult, appName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service)
@ -189,17 +190,17 @@ func testAccCheckHerokuAppAttributesUpdated(app *heroku.App, appName string) res
return fmt.Errorf("Bad name: %s", app.Name)
}
vars, err := client.ConfigVarInfo(app.Name)
vars, err := client.ConfigVarInfoForApp(context.TODO(), app.Name)
if err != nil {
return err
}
// Make sure we kept the old one
if vars["FOO"] != "bing" {
if vars["FOO"] == nil || *vars["FOO"] != "bing" {
return fmt.Errorf("Bad config vars: %v", vars)
}
if vars["BAZ"] != "bar" {
if vars["BAZ"] == nil || *vars["BAZ"] != "bar" {
return fmt.Errorf("Bad config vars: %v", vars)
}
@ -208,7 +209,7 @@ func testAccCheckHerokuAppAttributesUpdated(app *heroku.App, appName string) res
}
}
func testAccCheckHerokuAppAttributesNoVars(app *heroku.App, appName string) resource.TestCheckFunc {
func testAccCheckHerokuAppAttributesNoVars(app *heroku.AppInfoResult, appName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service)
@ -216,7 +217,7 @@ func testAccCheckHerokuAppAttributesNoVars(app *heroku.App, appName string) reso
return fmt.Errorf("Bad name: %s", app.Name)
}
vars, err := client.ConfigVarInfo(app.Name)
vars, err := client.ConfigVarInfoForApp(context.TODO(), app.Name)
if err != nil {
return err
}
@ -249,12 +250,12 @@ func testAccCheckHerokuAppAttributesOrg(app *heroku.OrganizationApp, appName str
return fmt.Errorf("Bad org: %v", app.Organization)
}
vars, err := client.ConfigVarInfo(app.Name)
vars, err := client.ConfigVarInfoForApp(context.TODO(), app.Name)
if err != nil {
return err
}
if vars["FOO"] != "bar" {
if vars["FOO"] == nil || *vars["FOO"] != "bar" {
return fmt.Errorf("Bad config vars: %v", vars)
}
@ -262,7 +263,7 @@ func testAccCheckHerokuAppAttributesOrg(app *heroku.OrganizationApp, appName str
}
}
func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFunc {
func testAccCheckHerokuAppExists(n string, app *heroku.AppInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
@ -276,7 +277,7 @@ func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFu
client := testAccProvider.Meta().(*heroku.Service)
foundApp, err := client.AppInfo(rs.Primary.ID)
foundApp, err := client.AppInfo(context.TODO(), rs.Primary.ID)
if err != nil {
return err
@ -306,7 +307,7 @@ func testAccCheckHerokuAppExistsOrg(n string, app *heroku.OrganizationApp) resou
client := testAccProvider.Meta().(*heroku.Service)
foundApp, err := client.OrganizationAppInfo(rs.Primary.ID)
foundApp, err := client.OrganizationAppInfo(context.TODO(), rs.Primary.ID)
if err != nil {
return err

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"log"
@ -16,28 +17,28 @@ func resourceHerokuCert() *schema.Resource {
Delete: resourceHerokuCertDelete,
Schema: map[string]*schema.Schema{
"app": &schema.Schema{
"app": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"certificate_chain": &schema.Schema{
"certificate_chain": {
Type: schema.TypeString,
Required: true,
},
"private_key": &schema.Schema{
"private_key": {
Type: schema.TypeString,
Required: true,
},
"cname": &schema.Schema{
"cname": {
Type: schema.TypeString,
Computed: true,
},
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
@ -56,7 +57,7 @@ func resourceHerokuCertCreate(d *schema.ResourceData, meta interface{}) error {
PrivateKey: d.Get("private_key").(string)}
log.Printf("[DEBUG] SSL Certificate create configuration: %#v, %#v", app, opts)
a, err := client.SSLEndpointCreate(app, opts)
a, err := client.SSLEndpointCreate(context.TODO(), app, opts)
if err != nil {
return fmt.Errorf("Error creating SSL endpoint: %s", err)
}
@ -92,7 +93,7 @@ func resourceHerokuCertUpdate(d *schema.ResourceData, meta interface{}) error {
preprocess := true
rollback := false
ad, err := client.SSLEndpointUpdate(
app, d.Id(), heroku.SSLEndpointUpdateOpts{
context.TODO(), app, d.Id(), heroku.SSLEndpointUpdateOpts{
CertificateChain: d.Get("certificate_chain").(*string),
Preprocess: &preprocess,
PrivateKey: d.Get("private_key").(*string),
@ -114,7 +115,7 @@ func resourceHerokuCertDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting SSL Cert: %s", d.Id())
// Destroy the app
err := client.SSLEndpointDelete(d.Get("app").(string), d.Id())
_, err := client.SSLEndpointDelete(context.TODO(), d.Get("app").(string), d.Id())
if err != nil {
return fmt.Errorf("Error deleting SSL Cert: %s", err)
}
@ -123,8 +124,8 @@ func resourceHerokuCertDelete(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceHerokuSSLCertRetrieve(app string, id string, client *heroku.Service) (*heroku.SSLEndpoint, error) {
addon, err := client.SSLEndpointInfo(app, id)
func resourceHerokuSSLCertRetrieve(app string, id string, client *heroku.Service) (*heroku.SSLEndpointInfoResult, error) {
addon, err := client.SSLEndpointInfo(context.TODO(), app, id)
if err != nil {
return nil, fmt.Errorf("Error retrieving SSL Cert: %s", err)

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"io/ioutil"
"os"
@ -13,7 +14,7 @@ import (
)
func TestAccHerokuCert_Basic(t *testing.T) {
var endpoint heroku.SSLEndpoint
var endpoint heroku.SSLEndpointInfoResult
wd, _ := os.Getwd()
certificateChainFile := wd + "/test-fixtures/terraform.cert"
certificateChainBytes, _ := ioutil.ReadFile(certificateChainFile)
@ -43,7 +44,7 @@ func TestAccHerokuCert_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuCertDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuCertConfig_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuCertExists("heroku_cert.ssl_certificate", &endpoint),
@ -65,7 +66,7 @@ func testAccCheckHerokuCertDestroy(s *terraform.State) error {
continue
}
_, err := client.SSLEndpointInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
_, err := client.SSLEndpointInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil {
return fmt.Errorf("Cerfificate still exists")
@ -75,7 +76,7 @@ func testAccCheckHerokuCertDestroy(s *terraform.State) error {
return nil
}
func testAccCheckHerokuCertificateChain(endpoint *heroku.SSLEndpoint, chain string) resource.TestCheckFunc {
func testAccCheckHerokuCertificateChain(endpoint *heroku.SSLEndpointInfoResult, chain string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if endpoint.CertificateChain != chain {
@ -86,7 +87,7 @@ func testAccCheckHerokuCertificateChain(endpoint *heroku.SSLEndpoint, chain stri
}
}
func testAccCheckHerokuCertExists(n string, endpoint *heroku.SSLEndpoint) resource.TestCheckFunc {
func testAccCheckHerokuCertExists(n string, endpoint *heroku.SSLEndpointInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
@ -100,7 +101,7 @@ func testAccCheckHerokuCertExists(n string, endpoint *heroku.SSLEndpoint) resour
client := testAccProvider.Meta().(*heroku.Service)
foundEndpoint, err := client.SSLEndpointInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
foundEndpoint, err := client.SSLEndpointInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err != nil {
return err

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"log"
@ -15,19 +16,19 @@ func resourceHerokuDomain() *schema.Resource {
Delete: resourceHerokuDomainDelete,
Schema: map[string]*schema.Schema{
"hostname": &schema.Schema{
"hostname": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"app": &schema.Schema{
"app": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"cname": &schema.Schema{
"cname": {
Type: schema.TypeString,
Computed: true,
},
@ -43,7 +44,7 @@ func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error
log.Printf("[DEBUG] Domain create configuration: %#v, %#v", app, hostname)
do, err := client.DomainCreate(app, heroku.DomainCreateOpts{Hostname: hostname})
do, err := client.DomainCreate(context.TODO(), app, heroku.DomainCreateOpts{Hostname: hostname})
if err != nil {
return err
}
@ -62,7 +63,7 @@ func resourceHerokuDomainDelete(d *schema.ResourceData, meta interface{}) error
log.Printf("[INFO] Deleting Domain: %s", d.Id())
// Destroy the domain
err := client.DomainDelete(d.Get("app").(string), d.Id())
_, err := client.DomainDelete(context.TODO(), d.Get("app").(string), d.Id())
if err != nil {
return fmt.Errorf("Error deleting domain: %s", err)
}
@ -74,7 +75,7 @@ func resourceHerokuDomainRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Service)
app := d.Get("app").(string)
do, err := client.DomainInfo(app, d.Id())
do, err := client.DomainInfo(context.TODO(), app, d.Id())
if err != nil {
return fmt.Errorf("Error retrieving domain: %s", err)
}

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"testing"
@ -11,7 +12,7 @@ import (
)
func TestAccHerokuDomain_Basic(t *testing.T) {
var domain heroku.Domain
var domain heroku.DomainInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
@ -19,7 +20,7 @@ func TestAccHerokuDomain_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuDomainDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuDomainConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuDomainExists("heroku_domain.foobar", &domain),
@ -45,7 +46,7 @@ func testAccCheckHerokuDomainDestroy(s *terraform.State) error {
continue
}
_, err := client.DomainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
_, err := client.DomainInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil {
return fmt.Errorf("Domain still exists")
@ -55,7 +56,7 @@ func testAccCheckHerokuDomainDestroy(s *terraform.State) error {
return nil
}
func testAccCheckHerokuDomainAttributes(Domain *heroku.Domain) resource.TestCheckFunc {
func testAccCheckHerokuDomainAttributes(Domain *heroku.DomainInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
if Domain.Hostname != "terraform.example.com" {
@ -66,7 +67,7 @@ func testAccCheckHerokuDomainAttributes(Domain *heroku.Domain) resource.TestChec
}
}
func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.TestCheckFunc {
func testAccCheckHerokuDomainExists(n string, Domain *heroku.DomainInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
@ -80,7 +81,7 @@ func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.Te
client := testAccProvider.Meta().(*heroku.Service)
foundDomain, err := client.DomainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
foundDomain, err := client.DomainInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err != nil {
return err

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"log"
"strings"
@ -18,19 +19,19 @@ func resourceHerokuDrain() *schema.Resource {
Delete: resourceHerokuDrainDelete,
Schema: map[string]*schema.Schema{
"url": &schema.Schema{
"url": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"app": &schema.Schema{
"app": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"token": &schema.Schema{
"token": {
Type: schema.TypeString,
Computed: true,
},
@ -48,9 +49,9 @@ func resourceHerokuDrainCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Drain create configuration: %#v, %#v", app, url)
var dr *heroku.LogDrain
var dr *heroku.LogDrainCreateResult
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
d, err := client.LogDrainCreate(app, heroku.LogDrainCreateOpts{URL: url})
d, err := client.LogDrainCreate(context.TODO(), app, heroku.LogDrainCreateOpts{URL: url})
if err != nil {
if strings.Contains(err.Error(), retryableError) {
return resource.RetryableError(err)
@ -78,7 +79,7 @@ func resourceHerokuDrainDelete(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Deleting drain: %s", d.Id())
// Destroy the drain
err := client.LogDrainDelete(d.Get("app").(string), d.Id())
_, err := client.LogDrainDelete(context.TODO(), d.Get("app").(string), d.Id())
if err != nil {
return fmt.Errorf("Error deleting drain: %s", err)
}
@ -89,7 +90,7 @@ func resourceHerokuDrainDelete(d *schema.ResourceData, meta interface{}) error {
func resourceHerokuDrainRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Service)
dr, err := client.LogDrainInfo(d.Get("app").(string), d.Id())
dr, err := client.LogDrainInfo(context.TODO(), d.Get("app").(string), d.Id())
if err != nil {
return fmt.Errorf("Error retrieving drain: %s", err)
}

View File

@ -1,6 +1,7 @@
package heroku
import (
"context"
"fmt"
"testing"
@ -11,7 +12,7 @@ import (
)
func TestAccHerokuDrain_Basic(t *testing.T) {
var drain heroku.LogDrain
var drain heroku.LogDrainInfoResult
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
@ -19,7 +20,7 @@ func TestAccHerokuDrain_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuDrainDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccCheckHerokuDrainConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuDrainExists("heroku_drain.foobar", &drain),
@ -42,7 +43,7 @@ func testAccCheckHerokuDrainDestroy(s *terraform.State) error {
continue
}
_, err := client.LogDrainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
_, err := client.LogDrainInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil {
return fmt.Errorf("Drain still exists")
@ -52,7 +53,7 @@ func testAccCheckHerokuDrainDestroy(s *terraform.State) error {
return nil
}
func testAccCheckHerokuDrainAttributes(Drain *heroku.LogDrain) resource.TestCheckFunc {
func testAccCheckHerokuDrainAttributes(Drain *heroku.LogDrainInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
if Drain.URL != "syslog://terraform.example.com:1234" {
@ -67,7 +68,7 @@ func testAccCheckHerokuDrainAttributes(Drain *heroku.LogDrain) resource.TestChec
}
}
func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.TestCheckFunc {
func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrainInfoResult) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
@ -81,7 +82,7 @@ func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.Te
client := testAccProvider.Meta().(*heroku.Service)
foundDrain, err := client.LogDrainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
foundDrain, err := client.LogDrainInfo(context.TODO(), rs.Primary.Attributes["app"], rs.Primary.ID)
if err != nil {
return err

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

5
vendor/vendor.json vendored
View File

@ -1262,9 +1262,10 @@
"revisionTime": "2016-07-14T17:28:59Z"
},
{
"checksumSHA1": "+LNqBN6tG7kPK8t4EIoNxk+VTvg=",
"checksumSHA1": "cSJrzeVJLa9x2xoVqrJLz2Y+l0Y=",
"path": "github.com/cyberdelia/heroku-go/v3",
"revision": "81c5afa1abcf69cc18ccc24fa3716b5a455c9208"
"revision": "58deda4c1fb0b4803387b29dc916c21887b81954",
"revisionTime": "2017-03-06T18:52:00Z"
},
{
"checksumSHA1": "/5cvgU+J4l7EhMXTK76KaCAfOuU=",