-
Notifications
You must be signed in to change notification settings - Fork 414
[Dashboards] Fix type error in unitScale #3238
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7628,7 +7628,7 @@ func buildDatadogFormula(data map[string]interface{}) *datadogV1.WidgetFormula { | |
| formula.SetStyle(*datadogFormulaStyle) | ||
| } | ||
| if number, ok := data["number_format"].([]interface{}); ok && len(number) != 0 { | ||
| datadogNumberFormat := buildNumberFormatFormulaSchema(number[0].(map[string]interface{})) | ||
| datadogNumberFormat := buildDatadogNumberFormatFormulaSchema(number[0].(map[string]interface{})) | ||
| formula.SetNumberFormat(*datadogNumberFormat) | ||
| } | ||
|
|
||
|
|
@@ -11057,7 +11057,7 @@ func getNumberFormatFormulaSchema() map[string]*schema.Schema { | |
| } | ||
| } | ||
|
|
||
| func buildNumberFormatFormulaSchema(terraformStyle map[string]interface{}) *datadogV1.WidgetNumberFormat { | ||
| func buildDatadogNumberFormatFormulaSchema(terraformStyle map[string]interface{}) *datadogV1.WidgetNumberFormat { | ||
| if terraformStyle == nil || len(terraformStyle) == 0 { | ||
| return nil | ||
| } | ||
|
|
@@ -11087,6 +11087,15 @@ func buildNumberFormatFormulaSchema(terraformStyle map[string]interface{}) *data | |
| } | ||
| } | ||
| } | ||
| if v, ok := terraformStyle["unit_scale"].([]interface{}); ok && len(v) > 0 { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't able to actually create a dashboard with this field with |
||
| unitScale := v[0].(map[string]interface{}) | ||
| if unitName, ok := unitScale["unit_name"].(string); ok && len(unitName) > 0 { | ||
| datadogNumber.UnitScale = *datadogV1.NewNullableNumberFormatUnitScale(&datadogV1.NumberFormatUnitScale{ | ||
| Type: datadogV1.NUMBERFORMATUNITSCALETYPE_CANONICAL_UNIT.Ptr(), | ||
| UnitName: datadog.PtrString(unitName), | ||
| }) | ||
| } | ||
| } | ||
| return &datadogNumber | ||
| } | ||
|
|
||
|
|
@@ -11106,8 +11115,7 @@ func buildTerraformNumberFormatFormulaSchema(datadogStyle datadogV1.WidgetNumber | |
| m["unit"] = []map[string]interface{}{unit} | ||
| } | ||
| if v, ok := datadogStyle.GetUnitScaleOk(); ok { | ||
| unitScale := map[string]interface{}{} | ||
| unitScale["unit_name"] = []map[string]interface{}{{"unit_name": v.UnitName}} | ||
| unitScale := map[string]interface{}{"unit_name": v.UnitName} | ||
| m["unit_scale"] = []map[string]interface{}{unitScale} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The schema for this is: so
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old code appears to be the cause of the error per the CI output:
aka it is saying that the first element of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure why the old code was working until Wednesday though this probably has something to do with the new release that day. |
||
| } | ||
| return []map[string]interface{}{m} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
buildDatadogfunctions are on the write path (turning HCL to Datadog schema), renamed this for clarity.