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

Properly add show_legend #329

Merged
merged 1 commit into from
Sep 30, 2019
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
6 changes: 6 additions & 0 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,9 @@ func buildDatadogTimeseriesDefinition(terraformDefinition map[string]interface{}
if v, ok := terraformDefinition["time"].(map[string]interface{}); ok && len(v) > 0 {
datadogDefinition.Time = buildDatadogWidgetTime(v)
}
if v, ok := terraformDefinition["show_legend"].(bool); ok {
datadogDefinition.ShowLegend = datadog.Bool(v)
}
return datadogDefinition
}

Expand Down Expand Up @@ -3065,6 +3068,9 @@ func buildTerraformTimeseriesDefinition(datadogDefinition datadog.TimeseriesDefi
if datadogDefinition.Time != nil {
terraformDefinition["time"] = buildTerraformWidgetTime(*datadogDefinition.Time)
}
if datadogDefinition.ShowLegend != nil {
terraformDefinition["show_legend"] = *datadogDefinition.ShowLegend
}
return terraformDefinition
}

Expand Down
2 changes: 2 additions & 0 deletions datadog/resource_datadog_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ resource "datadog_dashboard" "ordered_dashboard" {
label = " x=8 "
}
title = "Widget Title"
show_legend = true
time = {
live_span = "1h"
}
Expand Down Expand Up @@ -667,6 +668,7 @@ func TestAccDatadogDashboard_update(t *testing.T) {
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.marker.1.label", " x=8 "),
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.marker.1.value", "10 < y < 999"),
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.title", "Widget Title"),
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.show_legend", "true"),
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.time.live_span", "1h"),
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.event.0.q", "sources:test tags:1"),
resource.TestCheckResourceAttr("datadog_dashboard.ordered_dashboard", "widget.10.timeseries_definition.0.event.1.q", "sources:test tags:2"),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/dashboard.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ resource "datadog_dashboard" "ordered_dashboard" {
label = " x=8 "
}
title = "Widget Title"
show_legend = true
time = {
live_span = "1h"
}
Expand Down Expand Up @@ -737,6 +738,7 @@ Nested `widget` blocks have the following structure:
- `title_size`: (Optional) The size of the widget's title. Default is 16.
- `title_align`: (Optional) The alignment of the widget's title. One of "left", "center", or "right".
- `time`: (Optional) Nested block describing the timeframe to use when displaying the widget. The structure of this block is described [below](dashboard.html#nested-widget-time-blocks).
- `show_legend`: (Optional) Whether or not to show the legend on this widget.
- `event`: (Optional) The definition of the event to overlay on the graph. Includes the following structure:
- `q`: (Required) The event query to use in the widget
- `yaxis`: (Optional) Nested block describing the Y-Axis Controls. The structure of this block is described [below](dashboard.html#nested-widget-axis-blocks)
Expand Down