Skip to content

Commit

Permalink
fix(dashboards): fix to dashboard name update failure with filter_cur…
Browse files Browse the repository at this point in the history
…rent_dashboard
  • Loading branch information
pranav-new-relic committed Mar 21, 2024
1 parent 2292003 commit 88b308e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions newrelic/resource_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ func resourceNewRelicOneDashboardCreate(ctx context.Context, d *schema.ResourceD
defaultInfo := map[string]interface{}{
"account_id": accountID,
}
dashboard, err := expandDashboardInput(d, defaultInfo)
dashboard, err := expandDashboardInput(d, defaultInfo, "")
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -691,7 +691,7 @@ func resourceNewRelicOneDashboardCreate(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

dashboard, err := expandDashboardInput(d, defaultInfo)
dashboard, err := expandDashboardInput(d, defaultInfo, created.EntityResult.Name)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -748,7 +748,7 @@ func resourceNewRelicOneDashboardUpdate(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

dashboard, err := expandDashboardInput(d, defaultInfo)
dashboard, err := expandDashboardInput(d, defaultInfo, "")
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -783,7 +783,7 @@ func resourceNewRelicOneDashboardUpdate(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

dashboard, err = expandDashboardInput(d, defaultInfo)
dashboard, err = expandDashboardInput(d, defaultInfo, updated.EntityResult.Name)
if err != nil {
return diag.FromErr(err)
}
Expand Down
10 changes: 7 additions & 3 deletions newrelic/structures_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ import (

// Assemble the *dashboards.DashboardInput struct.
// Used by the newrelic_one_dashboard Create function.
func expandDashboardInput(d *schema.ResourceData, meta interface{}) (*dashboards.DashboardInput, error) {
func expandDashboardInput(d *schema.ResourceData, meta interface{}, dashboardNameCustom string) (*dashboards.DashboardInput, error) {
var err error

dash := dashboards.DashboardInput{
Name: d.Get("name").(string),
dash := dashboards.DashboardInput{}

if dashboardNameCustom != "" {
dash.Name = dashboardNameCustom
} else {
dash.Name = d.Get("name").(string)
}

dash.Pages, err = expandDashboardPageInput(d, d.Get("page").([]interface{}), meta)
Expand Down

0 comments on commit 88b308e

Please sign in to comment.