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
This commit is contained in:
Dan Thagard 2017-05-12 06:37:32 -04:00 committed by Paul Stack
parent a27e142625
commit 0a37f35865
2 changed files with 8 additions and 8 deletions

View File

@ -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
}

View File

@ -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",