From 0a37f358657c943e517c9e79e17cee909e41ea22 Mon Sep 17 00:00:00 2001 From: Dan Thagard Date: Fri, 12 May 2017 06:37:32 -0400 Subject: [PATCH] Allowed method on aggregator is `avg` ! `average` (#14414) * Allowed method on aggregator is `avg` ! `average` While Datadog will accept the value of `average` when creating the query graph, the resultant graph will be empty. Passing the value of `avg` instead correctly renders the graph. * Fixed gofmt * Updated test to match new aggregator method --- .../providers/datadog/resource_datadog_timeboard.go | 12 ++++++------ .../datadog/resource_datadog_timeboard_test.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/providers/datadog/resource_datadog_timeboard.go b/builtin/providers/datadog/resource_datadog_timeboard.go index 61a69dd47f..1f9efc8a77 100644 --- a/builtin/providers/datadog/resource_datadog_timeboard.go +++ b/builtin/providers/datadog/resource_datadog_timeboard.go @@ -704,15 +704,15 @@ func resourceDatadogTimeboardExists(d *schema.ResourceData, meta interface{}) (b func validateAggregatorMethod(v interface{}, k string) (ws []string, errors []error) { value := v.(string) validMethods := map[string]struct{}{ - "average": {}, - "max": {}, - "min": {}, - "sum": {}, - "last": {}, + "avg": {}, + "max": {}, + "min": {}, + "sum": {}, + "last": {}, } if _, ok := validMethods[value]; !ok { errors = append(errors, fmt.Errorf( - `%q contains an invalid method %q. Valid methods are either "average", "max", "min", "sum", or "last"`, k, value)) + `%q contains an invalid method %q. Valid methods are either "avg", "max", "min", "sum", or "last"`, k, value)) } return } diff --git a/builtin/providers/datadog/resource_datadog_timeboard_test.go b/builtin/providers/datadog/resource_datadog_timeboard_test.go index 87498c7360..3673b95064 100644 --- a/builtin/providers/datadog/resource_datadog_timeboard_test.go +++ b/builtin/providers/datadog/resource_datadog_timeboard_test.go @@ -224,7 +224,7 @@ func checkDestroy(s *terraform.State) error { func TestValidateAggregatorMethod(t *testing.T) { validMethods := []string{ - "average", + "avg", "max", "min", "sum", @@ -237,7 +237,7 @@ func TestValidateAggregatorMethod(t *testing.T) { } invalidMethods := []string{ - "avg", + "average", "suM", "m", "foo",