Skip to content

Commit b5d08b2

Browse files
committed
Use ImportStatePassthrough
1 parent 16eebfc commit b5d08b2

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

grafana/resource_dashboard.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package grafana
22

33
import (
44
"encoding/json"
5-
"errors"
65
"fmt"
76
"log"
87

@@ -18,7 +17,7 @@ func ResourceDashboard() *schema.Resource {
1817
Update: UpdateDashboard,
1918
Delete: DeleteDashboard,
2019
Importer: &schema.ResourceImporter{
21-
State: ImportDashboard,
20+
State: schema.ImportStatePassthrough,
2221
},
2322

2423
Schema: map[string]*schema.Schema{
@@ -120,15 +119,6 @@ func DeleteDashboard(d *schema.ResourceData, meta interface{}) error {
120119
return client.DeleteDashboard(slug)
121120
}
122121

123-
func ImportDashboard(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
124-
err := ReadDashboard(d, meta)
125-
126-
if err != nil || d.Id() == "" {
127-
return nil, errors.New(fmt.Sprintf("Error: Unable to import Grafana Dashboard: %s.", err))
128-
}
129-
return []*schema.ResourceData{d}, nil
130-
}
131-
132122
func prepareDashboardModel(configJSON string) map[string]interface{} {
133123
configMap := map[string]interface{}{}
134124
err := json.Unmarshal([]byte(configJSON), &configMap)

grafana/resource_dashboard_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestAccDashboard_disappear(t *testing.T) {
8787
Providers: testAccProviders,
8888
CheckDestroy: testAccDashboardCheckDestroy(&dashboard),
8989
Steps: []resource.TestStep{
90-
resource.TestStep{
90+
{
9191
Config: testAccDashboardConfig_disappear,
9292
Check: resource.ComposeTestCheckFunc(
9393
testAccDashboardCheckExists("grafana_dashboard.test", &dashboard),

0 commit comments

Comments
 (0)