Update function name for kapacitor's formatting of values

pull/10616/head
Chris Goller 2017-02-10 10:06:26 -06:00
parent a523350bf0
commit 27bafdab53
1 changed files with 4 additions and 8 deletions

View File

@ -40,10 +40,7 @@ func Vars(rule chronograf.AlertRule) (string, error) {
%s %s
var crit = %s var crit = %s
` `
// If critical value is a string, we'll return fmt.Sprintf(vars, common, formatValue(rule.TriggerValues.Value)), nil
// need to single-quote it.
crit := critVar(rule.TriggerValues.Value)
return fmt.Sprintf(vars, common, crit), nil
} else { } else {
vars := ` vars := `
%s %s
@ -181,10 +178,9 @@ func whereFilter(q chronograf.QueryConfig) string {
return "lambda: TRUE" return "lambda: TRUE"
} }
// critVar return the same string if a numeric type // formatValue return the same string if a numeric type or if it is a string
// or if it is a string will return it as a kapacitor // will return it as a kapacitor formatted single-quoted string
// formatted single-quoted string func formatValue(value string) string {
func critVar(value string) string {
// Test if numeric if it can be converted to a float // Test if numeric if it can be converted to a float
if _, err := strconv.ParseFloat(value, 64); err == nil { if _, err := strconv.ParseFloat(value, 64); err == nil {
return value return value