浏览代码

add a 'Upper' expr helper

Thibault bui Koechlin 5 年之前
父节点
当前提交
ccf6ff212d
共有 1 个文件被更改,包括 11 次插入6 次删除
  1. 11 6
      pkg/exprhelpers/exprlib.go

+ 11 - 6
pkg/exprhelpers/exprlib.go

@@ -32,15 +32,20 @@ func EndsWith(s string, suff string) bool {
 	return strings.HasSuffix(s, suff)
 }
 
+func Upper(s string) string {
+	return strings.ToUpper(s)
+}
+
 func GetExprEnv(ctx map[string]interface{}) map[string]interface{} {
 	var ExprLib = map[string]interface{}{
-		"Atof": Atof,
-		"StartsWith": StartsWith,
-		"EndsWith" : EndsWith,
-		"JsonExtract": JsonExtract,
+		"Atof":           Atof,
+		"StartsWith":     StartsWith,
+		"EndsWith":       EndsWith,
+		"JsonExtract":    JsonExtract,
 		"JsonExtractLib": JsonExtractLib,
-		"File": File,
-		"RegexpInFile": RegexpInFile,
+		"File":           File,
+		"RegexpInFile":   RegexpInFile,
+		"Upper":          Upper,
 	}
 	for k, v := range ctx {
 		ExprLib[k] = v