Add type and styles to datadog timeboard graphs

Create the resources for title and styles and add them to the acceptance
test. Styles currently only support "palette".
This commit is contained in:
Colin Saliceti 2016-10-03 16:18:18 +01:00
parent b53d7a7b49
commit cae5d8bbb9
2 changed files with 25 additions and 0 deletions

View File

@ -26,6 +26,15 @@ func resourceDatadogTimeboard() *schema.Resource {
Optional: true,
Default: false,
},
"type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "line",
},
"style": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
},
},
},
}
@ -121,10 +130,17 @@ func appendRequests(datadogGraph *datadog.Graph, terraformRequests *[]interface{
t := t_.(map[string]interface{})
d := datadog.GraphDefinitionRequest{
Query: t["q"].(string),
Type: t["type"].(string),
}
if stacked, ok := t["stacked"]; ok {
d.Stacked = stacked.(bool)
}
if style, ok := t["style"]; ok {
s, _ := style.(map[string]interface{})
if palette, ok := s["palette"]; ok {
d.Style.Palette = palette.(string)
}
}
datadogGraph.Definition.Requests = append(datadogGraph.Definition.Requests, d)
}
}

View File

@ -47,6 +47,13 @@ resource "datadog_timeboard" "acceptance_test" {
request {
q = "avg:redis.mem.rss{$host}"
}
request {
q = "avg:redis.mem.rss{$host}"
type = "bars"
style {
palette = "warm"
}
}
}
template_variable {
name = "host"
@ -86,6 +93,8 @@ func TestAccDatadogTimeboard_update(t *testing.T) {
resource.TestCheckResourceAttr("datadog_timeboard.acceptance_test", "graph.1.request.1.q", "avg:redis.mem.rss{$host}"),
resource.TestCheckResourceAttr("datadog_timeboard.acceptance_test", "template_variable.0.name", "host"),
resource.TestCheckResourceAttr("datadog_timeboard.acceptance_test", "template_variable.0.prefix", "host"),
resource.TestCheckResourceAttr("datadog_timeboard.acceptance_test", "graph.1.request.2.type", "bars"),
resource.TestCheckResourceAttr("datadog_timeboard.acceptance_test", "graph.1.request.2.style.palette", "warm"),
),
}