providers/heroku: import heroku_pipeline resource (#14486)

This commit is contained in:
cmorent 2017-05-15 16:12:29 +02:00 committed by Clint
parent 5a3cf7c89e
commit 589febdc26
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package heroku
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccHerokuPipeline_importBasic(t *testing.T) {
pName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuPipelineDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckHerokuPipelineConfig_basic(pName),
},
{
ResourceName: "heroku_pipeline.foobar",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"config_vars"},
},
},
})
}

View File

@ -16,6 +16,10 @@ func resourceHerokuPipeline() *schema.Resource {
Read: resourceHerokuPipelineRead,
Delete: resourceHerokuPipelineDelete,
Importer: &schema.ResourceImporter{
State: resourceHerokuPipelineImport,
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
@ -25,6 +29,19 @@ func resourceHerokuPipeline() *schema.Resource {
}
}
func resourceHerokuPipelineImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
client := meta.(*heroku.Service)
p, err := client.PipelineInfo(context.TODO(), d.Id())
if err != nil {
return nil, err
}
d.Set("name", p.Name)
return []*schema.ResourceData{d}, nil
}
func resourceHerokuPipelineCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*heroku.Service)