Skip to content

Commit

Permalink
add validation to query options
Browse files Browse the repository at this point in the history
  • Loading branch information
platinummonkey committed Aug 13, 2019
1 parent 1eb55bc commit 6338ed2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions datadog/resource_datadog_service_level_objective.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ func resourceDatadogServiceLevelObjective() *schema.Resource {
StateFunc: func(val interface{}) string {
return strings.TrimSpace(val.(string))
},
ValidateFunc: validQueryOption,
},
"denominator": {
Type: schema.TypeString,
Required: true,
StateFunc: func(val interface{}) string {
return strings.TrimSpace(val.(string))
},
ValidateFunc: validQueryOption,
},
},
},
Expand Down Expand Up @@ -487,3 +489,13 @@ func suppressDataDogSLODisplayValueDiff(k, old, new string, d *schema.ResourceDa

return suppressDataDogFloatIntDiff(k, old, new, d)
}

// validQueryOption validates that the `query` parameter is naively valid.
func validQueryOption(v interface{}, k string) (ws []string, errors []error) {
strVal := strings.TrimSpace(v.(string))
if strVal == "" {
errors = append(errors, fmt.Errorf("empty `query.%s` specified for SLO", k))
return
}
return
}

0 comments on commit 6338ed2

Please sign in to comment.