Use new Datadog GraphDefinitionRequest struct

This new struct avoids requiring to repeat the struct definition in this
code here. It avoids duplication and makes it more flexible so more
options can be added to the struct without breaking the code here.
This commit is contained in:
Colin Saliceti 2016-10-03 12:15:01 +01:00
parent 982a065863
commit b53d7a7b49
1 changed files with 3 additions and 6 deletions

View File

@ -119,12 +119,9 @@ func buildTemplateVariables(terraformTemplateVariables *[]interface{}) *[]datado
func appendRequests(datadogGraph *datadog.Graph, terraformRequests *[]interface{}) {
for _, t_ := range *terraformRequests {
t := t_.(map[string]interface{})
d := struct {
Query string `json:"q"`
Stacked bool `json:"stacked"`
Aggregator string
ConditionalFormats []datadog.DashboardConditionalFormat `json:"conditional_formats,omitempty"`
}{Query: t["q"].(string)}
d := datadog.GraphDefinitionRequest{
Query: t["q"].(string),
}
if stacked, ok := t["stacked"]; ok {
d.Stacked = stacked.(bool)
}