Skip to content

Commit

Permalink
[dashboards] Safely type assert optional fields from log and apm query (
Browse files Browse the repository at this point in the history
#283)

* Safely type assert optional fields from log and apm query

* Updates dashboard documentation
  • Loading branch information
jbenais authored and nmuesch committed Aug 13, 2019
1 parent 8f86f8c commit 6296b6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3789,8 +3789,10 @@ func buildDatadogApmOrLogQuery(terraformQuery map[string]interface{}) *datadog.W
if v, ok := terraformCompute["facet"].(string); ok && len(v) != 0 {
datadogCompute.Facet = datadog.String(v)
}
if v, err := strconv.ParseInt(terraformCompute["interval"].(string), 10, 64); err == nil {
datadogCompute.Interval = datadog.Int(int(v))
if interval, ok := terraformCompute["interval"].(string); ok && len(interval) != 0 {
if v, err := strconv.ParseInt(interval, 10, 64); err == nil {
datadogCompute.Interval = datadog.Int(int(v))
}
}
datadogQuery.Compute = &datadogCompute
// Search
Expand Down Expand Up @@ -3818,7 +3820,7 @@ func buildDatadogApmOrLogQuery(terraformQuery map[string]interface{}) *datadog.W
Aggregation: datadog.String(sort["aggregation"].(string)),
Order: datadog.String(sort["order"].(string)),
}
if len(sort["facet"].(string)) > 0 {
if facet, ok := sort["facet"].(string); ok && len(facet) > 0 {
datadogGroupBy.Sort.Facet = datadog.String(sort["facet"].(string))
}
}
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/dashboard.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ Nested `apm_query` and `log_query` blocks have the following structure (Visit th
- `facet` - (Optional)
- `limit` - (Optional)
- `sort` - (Optional). One nested block is allowed with the following structure:
- `aggregation` - (Optional)
- `order` - (Optional)
- `aggregation` - (Required)
- `order` - (Required)
- `facet` - (Optional)


Expand Down

0 comments on commit 6296b6d

Please sign in to comment.