mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
providers/heroku: import heroku_pipeline_coupling resource (#14495)
This commit is contained in:
parent
f8b1d81ed8
commit
0c260d1341
@ -0,0 +1,43 @@
|
|||||||
|
package heroku
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
heroku "github.com/cyberdelia/heroku-go/v3"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccHerokuPipelineCoupling_importBasic(t *testing.T) {
|
||||||
|
var coupling heroku.PipelineCouplingInfoResult
|
||||||
|
|
||||||
|
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
|
||||||
|
pipelineName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
|
||||||
|
stageName := "development"
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckHerokuPipelineCouplingDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccCheckHerokuPipelineCouplingConfig_basic(appName, pipelineName, stageName),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckHerokuPipelineCouplingExists("heroku_pipeline_coupling.default", &coupling),
|
||||||
|
testAccCheckHerokuPipelineCouplingAttributes(
|
||||||
|
&coupling,
|
||||||
|
"heroku_pipeline.default",
|
||||||
|
stageName,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ResourceName: "heroku_pipeline_coupling.default",
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{"config_vars"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@ -15,7 +15,15 @@ func resourceHerokuPipelineCoupling() *schema.Resource {
|
|||||||
Read: resourceHerokuPipelineCouplingRead,
|
Read: resourceHerokuPipelineCouplingRead,
|
||||||
Delete: resourceHerokuPipelineCouplingDelete,
|
Delete: resourceHerokuPipelineCouplingDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: schema.ImportStatePassthrough,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
"app_id": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"app": {
|
"app": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
@ -81,9 +89,17 @@ func resourceHerokuPipelineCouplingRead(d *schema.ResourceData, meta interface{}
|
|||||||
return fmt.Errorf("Error retrieving pipeline: %s", err)
|
return fmt.Errorf("Error retrieving pipeline: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("app", p.App)
|
// grab App info
|
||||||
d.Set("pipeline", p.Pipeline)
|
app, err := client.AppInfo(context.TODO(), p.App.ID)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[WARN] Error looking up addional App info for pipeline coupling (%s): %s", d.Id(), err)
|
||||||
|
} else {
|
||||||
|
d.Set("app", app.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Set("app_id", p.App.ID)
|
||||||
d.Set("stage", p.Stage)
|
d.Set("stage", p.Stage)
|
||||||
|
d.Set("pipeline", p.Pipeline.ID)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user