Skip to content

Commit

Permalink
fix(dashboard): fixed PR Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vinay-newrelic committed Aug 29, 2024
1 parent 4633984 commit 7f3c8cd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions newrelic/structures_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ func expandDashboardInput(d *schema.ResourceData, meta interface{}, dashboardNam
return &dash, nil
}

func checkForNilElements(d []interface{}) bool {
for _, item := range d {
if item == nil {
return true
}
}
return false
}

func expandDashboardVariablesInput(variables []interface{}) ([]dashboards.DashboardVariableInput, error) {
if len(variables) < 1 {
return []dashboards.DashboardVariableInput{}, nil
Expand All @@ -65,13 +74,7 @@ func expandDashboardVariablesInput(variables []interface{}) ([]dashboards.Dashbo

if d, ok := v["default_values"].([]interface{}); ok && d != nil && len(d) >= 0 {
// Check if the slice is empty or contains only nil elements as we are receiving d as [<nil>] when an empty string is given
hasNil := false
for _, item := range d {
if item == nil {
hasNil = true
break
}
}
hasNil := checkForNilElements(d)
if len(d) > 0 && !hasNil {
variable.DefaultValues = expandVariableDefaultValues(d)
} else {
Expand Down

0 comments on commit 7f3c8cd

Please sign in to comment.