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] Add support for sunburst widget request style #2089

Merged
merged 8 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5926,6 +5926,16 @@ func getSunburstRequestSchema() map[string]*schema.Schema {
// "query" and "formula" go together
"query": getFormulaQuerySchema(),
"formula": getFormulaSchema(),
// Settings specific to Sunburst requests
"style": {
Description: "Define style for the widget's request.",
Copy link
Contributor Author

@matt-miller-ddog matt-miller-ddog Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I flipped the wording compared to how Heatmaps describe this. (I think it makes more sense this way, but let me know if I should change it.)

Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: &schema.Resource{
Schema: getWidgetRequestStyle(),
},
},
}
}

Expand Down Expand Up @@ -6070,6 +6080,11 @@ func buildDatadogSunburstRequests(terraformRequests *[]interface{}) *[]datadogV1
}
datadogSunburstRequest.SetFormulas(formulas)
}
if style, ok := terraformRequest["style"].([]interface{}); ok && len(style) > 0 {
if v, ok := style[0].(map[string]interface{}); ok && len(v) > 0 {
datadogSunburstRequest.Style = buildDatadogWidgetStyle(v)
}
}
datadogRequests[i] = *datadogSunburstRequest
}
return &datadogRequests
Expand Down Expand Up @@ -6109,6 +6124,10 @@ func buildTerraformSunburstRequests(datadogSunburstRequests *[]datadogV1.Sunburs
if v, ok := datadogRequest.GetFormulasOk(); ok {
terraformRequest["formula"] = buildTerraformFormula(v)
}
if v, ok := datadogRequest.GetStyleOk(); ok {
style := buildTerraformWidgetStyle(*v)
terraformRequest["style"] = []map[string]interface{}{style}
}
terraformRequests[i] = terraformRequest
}
return &terraformRequests
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:39.486019-04:00
2023-08-31T13:02:55.221453-04:00
24 changes: 12 additions & 12 deletions datadog/tests/cassettes/TestAccDatadogDashboardSunburst.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:39.144014-04:00
2023-08-31T13:02:55.221405-04:00

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions datadog/tests/resource_datadog_dashboard_sunburst_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ resource "datadog_dashboard" "sunburst_dashboard" {
title = "{{uniq}}"
description = "Created using the Datadog provider in Terraform"
layout_type = "ordered"
is_read_only = true
widget {
sunburst_definition {
request {
Expand All @@ -25,6 +24,9 @@ resource "datadog_dashboard" "sunburst_dashboard" {
aggregator = "sum"
}
}
style {
palette = "dog_classic"
}
}
hide_total = false
legend_inline {
Expand Down Expand Up @@ -97,13 +99,13 @@ var datadogDashboardSunburstAsserts = []string{
"description = Created using the Datadog provider in Terraform",
"layout_type = ordered",
"title = {{uniq}}",
"is_read_only = true",
"widget.0.sunburst_definition.0.request.0.formula.0.formula_expression = my_query_1 + my_query_2",
"widget.0.sunburst_definition.0.request.0.formula.0.alias = my ff query",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.data_source = metrics",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.query = avg:system.cpu.user{foo:bar} by {env}",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.name = my_query_1",
"widget.0.sunburst_definition.0.request.0.query.0.metric_query.0.aggregator = sum",
"widget.0.sunburst_definition.0.request.0.style.0.palette = dog_classic",
"widget.0.sunburst_definition.0.hide_total = false",
"widget.0.sunburst_definition.0.legend_inline.0.type = automatic",
"widget.0.sunburst_definition.0.legend_inline.0.hide_value = true",
Expand Down
22 changes: 20 additions & 2 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4625,7 +4625,7 @@ Required:

Required:

- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.
- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `trace_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.
nkzou marked this conversation as resolved.
Show resolved Hide resolved

Optional:

Expand Down Expand Up @@ -6954,6 +6954,7 @@ Optional:
- `query` (Block List) (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--query))
- `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--rum_query))
- `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--security_query))
- `style` (Block List, Max: 1) Define style for the widget's request. (see [below for nested schema](#nestedblock--widget--group_definition--widget--sunburst_definition--request--style))

<a id="nestedblock--widget--group_definition--widget--sunburst_definition--request--apm_query"></a>
### Nested Schema for `widget.group_definition.widget.sunburst_definition.request.apm_query`
Expand Down Expand Up @@ -7573,6 +7574,14 @@ Optional:



<a id="nestedblock--widget--group_definition--widget--sunburst_definition--request--style"></a>
### Nested Schema for `widget.group_definition.widget.sunburst_definition.request.style`

Optional:

- `palette` (String) A color palette to apply to the widget. The available options are available at: https://docs.datadoghq.com/dashboards/widgets/timeseries/#appearance.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it intentional that we're linking to the timeseries docs here? If these docs are generated then we may need to fix it upstream





<a id="nestedblock--widget--group_definition--widget--timeseries_definition"></a>
Expand Down Expand Up @@ -10283,7 +10292,7 @@ Required:

Required:

- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.
- `data_source` (String) Source from which to query items to display in the stream. Valid values are `logs_stream`, `audit_stream`, `ci_pipeline_stream`, `ci_test_stream`, `rum_issue_stream`, `apm_issue_stream`, `trace_stream`, `logs_issue_stream`, `logs_pattern_stream`, `logs_transaction_stream`, `event_stream`.

Optional:

Expand Down Expand Up @@ -12612,6 +12621,7 @@ Optional:
- `query` (Block List) (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--query))
- `rum_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--rum_query))
- `security_query` (Block List, Max: 1) The query to use for this widget. (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--security_query))
- `style` (Block List, Max: 1) Define style for the widget's request. (see [below for nested schema](#nestedblock--widget--sunburst_definition--request--style))

<a id="nestedblock--widget--sunburst_definition--request--apm_query"></a>
### Nested Schema for `widget.sunburst_definition.request.apm_query`
Expand Down Expand Up @@ -13231,6 +13241,14 @@ Optional:



<a id="nestedblock--widget--sunburst_definition--request--style"></a>
### Nested Schema for `widget.sunburst_definition.request.style`

Optional:

- `palette` (String) A color palette to apply to the widget. The available options are available at: https://docs.datadoghq.com/dashboards/widgets/timeseries/#appearance.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it intentional that we're linking to the timeseries docs here? If these docs are generated then we may need to fix it upstream

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like most of the widget request styles share the same schema from getWidgetRequestStyle() line 9192 of resource_datadog_dashboard.go. Is there a more generic list of styles that could be linked to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really want to rock the boat here; but, offhand, https://docs.datadoghq.com/dashboards/guide/widget_colors/ looks like a better page; at the very least we should replace #appearance with #color so it links right.

I'll run this by Dataviz and see what they advise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: it's on their radar. They're going to do a review of color docs, as I think there are a few more stale things beyond just this.





<a id="nestedblock--widget--timeseries_definition"></a>
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/terraform-providers/terraform-provider-datadog

require (
github.com/DataDog/datadog-api-client-go/v2 v2.16.0
github.com/DataDog/datadog-api-client-go/v2 v2.16.1-0.20230831134252-8a2ecace0920
github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad
github.com/dnaeon/go-vcr v1.0.1
github.com/hashicorp/go-cleanhttp v0.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-api-client-go/v2 v2.16.0 h1:wwroXLmBlO5/o+uS1UxDpuMIkhIL6gJAu6m0ttGM5Yc=
github.com/DataDog/datadog-api-client-go/v2 v2.16.0/go.mod h1:uJd7G1BONVIyiVw684VMn2XYI1FfN1tx4bRGenAf2bo=
github.com/DataDog/datadog-api-client-go/v2 v2.16.1-0.20230831134252-8a2ecace0920 h1:coE+poJvFIhpoUd044OQ1I/mHZntpVBvzcVWaXmpshk=
github.com/DataDog/datadog-api-client-go/v2 v2.16.1-0.20230831134252-8a2ecace0920/go.mod h1:uJd7G1BONVIyiVw684VMn2XYI1FfN1tx4bRGenAf2bo=
github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down