providers/heroku: import heroku_pipeline resource (#14486)
This commit is contained in:
parent
5a3cf7c89e
commit
589febdc26
|
@ -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"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -16,6 +16,10 @@ func resourceHerokuPipeline() *schema.Resource {
|
||||||
Read: resourceHerokuPipelineRead,
|
Read: resourceHerokuPipelineRead,
|
||||||
Delete: resourceHerokuPipelineDelete,
|
Delete: resourceHerokuPipelineDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: resourceHerokuPipelineImport,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
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 {
|
func resourceHerokuPipelineCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
client := meta.(*heroku.Service)
|
client := meta.(*heroku.Service)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue