providers/heroku: init addon, app update
This commit is contained in:
parent
3a2db580d0
commit
5a178a39a0
|
@ -0,0 +1 @@
|
||||||
|
package heroku
|
|
@ -0,0 +1 @@
|
||||||
|
package heroku
|
|
@ -101,10 +101,29 @@ func resource_heroku_app_update(
|
||||||
s *terraform.ResourceState,
|
s *terraform.ResourceState,
|
||||||
d *terraform.ResourceDiff,
|
d *terraform.ResourceDiff,
|
||||||
meta interface{}) (*terraform.ResourceState, error) {
|
meta interface{}) (*terraform.ResourceState, error) {
|
||||||
|
p := meta.(*ResourceProvider)
|
||||||
|
client := p.client
|
||||||
|
rs := s.MergeDiff(d)
|
||||||
|
|
||||||
panic("does not update")
|
if attr, ok := d.Attributes["name"]; ok {
|
||||||
|
opts := heroku.AppUpdateOpts{
|
||||||
|
Name: &attr.New,
|
||||||
|
}
|
||||||
|
|
||||||
return nil, nil
|
_, err := client.AppUpdate(rs.ID, &opts)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return s, err
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
app, err := resource_heroku_app_retrieve(rs.ID, client)
|
||||||
|
if err != nil {
|
||||||
|
return rs, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource_heroku_app_update_state(rs, app)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resource_heroku_app_destroy(
|
func resource_heroku_app_destroy(
|
||||||
|
|
|
@ -32,6 +32,42 @@ func TestAccHerokuApp_Basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccHerokuApp_NameChange(t *testing.T) {
|
||||||
|
var app heroku.App
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckHerokuAppDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccCheckHerokuAppConfig_basic,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
|
||||||
|
testAccCheckHerokuAppAttributes(&app),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"heroku_app.foobar", "name", "terraform-test-app"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"heroku_app.foobar", "config_vars.0.FOO", "bar"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccCheckHerokuAppConfig_updated,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
|
||||||
|
testAccCheckHerokuAppAttributesUpdated(&app),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"heroku_app.foobar", "name", "terraform-test-renamed"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"heroku_app.foobar", "config_vars.0.FOO", "bing"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"heroku_app.foobar", "config_vars.0.BAZ", "bar"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckHerokuAppDestroy(s *terraform.State) error {
|
func testAccCheckHerokuAppDestroy(s *terraform.State) error {
|
||||||
client := testAccProvider.client
|
client := testAccProvider.client
|
||||||
|
|
||||||
|
@ -79,6 +115,33 @@ func testAccCheckHerokuAppAttributes(app *heroku.App) resource.TestCheckFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccCheckHerokuAppAttributesUpdated(app *heroku.App) resource.TestCheckFunc {
|
||||||
|
return func(s *terraform.State) error {
|
||||||
|
client := testAccProvider.client
|
||||||
|
|
||||||
|
if app.Name != "terraform-test-renamed" {
|
||||||
|
return fmt.Errorf("Bad name: %s", app.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
vars, err := client.ConfigVarInfo(app.Name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we kept the old one
|
||||||
|
if vars["FOO"] != "bing" {
|
||||||
|
return fmt.Errorf("Bad config vars: %v", vars)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars["BAZ"] != "bar" {
|
||||||
|
return fmt.Errorf("Bad config vars: %v", vars)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFunc {
|
func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.Resources[n]
|
rs, ok := s.Resources[n]
|
||||||
|
@ -117,3 +180,13 @@ resource "heroku_app" "foobar" {
|
||||||
FOO = bar
|
FOO = bar
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
const testAccCheckHerokuAppConfig_updated = `
|
||||||
|
resource "heroku_app" "foobar" {
|
||||||
|
name = "terraform-test-renamed"
|
||||||
|
|
||||||
|
config_vars = {
|
||||||
|
FOO = bing
|
||||||
|
BAZ = bar
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
Loading…
Reference in New Issue