crowdsec/pkg/exprhelpers/exprlib.go
2020-05-22 18:12:33 +02:00

26 lines
525 B
Go

package exprhelpers
import (
"strconv"
log "github.com/sirupsen/logrus"
)
func Atof(x string) float64 {
log.Debugf("debug atof %s", x)
ret, err := strconv.ParseFloat(x, 64)
if err != nil {
log.Warningf("Atof : can't convert float '%s' : %v", x, err)
}
return ret
}
func GetExprEnv(ctx map[string]interface{}) map[string]interface{} {
var ExprLib = map[string]interface{}{"Atof": Atof, "JsonExtract": JsonExtract, "JsonExtractLib": JsonExtractLib}
for k, v := range ctx {
ExprLib[k] = v
}
return ExprLib
}