Skip to content

Commit

Permalink
Properly add show_legend (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmuesch authored Sep 30, 2019
1 parent 262e4a3 commit cf4d1ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
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

0 comments on commit cf4d1ce

Please sign in to comment.