Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[datadog_dashboard] Safeguard against empty formula definitions #1838

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,9 @@ func buildDatadogChangeRequests(terraformRequests *[]interface{}) *[]datadogV1.C
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogChangeRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -3876,6 +3879,9 @@ func buildDatadogQueryValueRequests(terraformRequests *[]interface{}) *[]datadog
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogQueryValueRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -4149,6 +4155,9 @@ func buildDatadogQueryTableRequests(terraformRequests *[]interface{}) *[]datadog
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogQueryTableRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -5489,6 +5498,9 @@ func buildDatadogGeomapRequests(terraformRequests *[]interface{}) *[]datadogV1.G
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogGeomapRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -5978,6 +5990,9 @@ func buildDatadogSunburstRequests(terraformRequests *[]interface{}) *[]datadogV1
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogSunburstRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -6921,6 +6936,9 @@ func buildDatadogTimeseriesRequests(terraformRequests *[]interface{}) *[]datadog
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogTimeseriesRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -7202,6 +7220,9 @@ func buildDatadogToplistRequests(terraformRequests *[]interface{}) *[]datadogV1.
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogToplistRequest.SetFormulas(formulas)
Expand Down Expand Up @@ -7605,6 +7626,9 @@ func buildDatadogTreemapRequests(terraformRequests *[]interface{}) *[]datadogV1.
if v, ok := terraformRequest["formula"].([]interface{}); ok && len(v) > 0 {
formulas := make([]datadogV1.WidgetFormula, len(v))
for i, formula := range v {
if formula == nil {
continue
}
formulas[i] = buildDatadogFormula(formula.(map[string]interface{}))
}
datadogTreemapRequest.SetFormulas(formulas)
Expand Down