Skip to content

Commit

Permalink
Use ImportStatePassthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed Jun 26, 2019
1 parent 16eebfc commit b5d08b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions grafana/resource_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package grafana

import (
"encoding/json"
"errors"
"fmt"
"log"

Expand All @@ -18,7 +17,7 @@ func ResourceDashboard() *schema.Resource {
Update: UpdateDashboard,
Delete: DeleteDashboard,
Importer: &schema.ResourceImporter{
State: ImportDashboard,
State: schema.ImportStatePassthrough,
},

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

func ImportDashboard(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
err := ReadDashboard(d, meta)

if err != nil || d.Id() == "" {
return nil, errors.New(fmt.Sprintf("Error: Unable to import Grafana Dashboard: %s.", err))
}
return []*schema.ResourceData{d}, nil
}

func prepareDashboardModel(configJSON string) map[string]interface{} {
configMap := map[string]interface{}{}
err := json.Unmarshal([]byte(configJSON), &configMap)
Expand Down
2 changes: 1 addition & 1 deletion grafana/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestAccDashboard_disappear(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccDashboardCheckDestroy(&dashboard),
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccDashboardConfig_disappear,
Check: resource.ComposeTestCheckFunc(
testAccDashboardCheckExists("grafana_dashboard.test", &dashboard),
Expand Down

0 comments on commit b5d08b2

Please sign in to comment.