|
|
|
|
@ -3,6 +3,7 @@ package config
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"crypto/sha1"
|
|
|
|
|
"crypto/sha256"
|
|
|
|
|
"encoding/base64"
|
|
|
|
|
"encoding/hex"
|
|
|
|
|
"errors"
|
|
|
|
|
@ -39,6 +40,7 @@ func Funcs() map[string]ast.Function {
|
|
|
|
|
"replace": interpolationFuncReplace(),
|
|
|
|
|
"split": interpolationFuncSplit(),
|
|
|
|
|
"sha1": interpolationFuncSha1(),
|
|
|
|
|
"sha256": interpolationFuncSha256(),
|
|
|
|
|
"base64encode": interpolationFuncBase64Encode(),
|
|
|
|
|
"base64decode": interpolationFuncBase64Decode(),
|
|
|
|
|
"upper": interpolationFuncUpper(),
|
|
|
|
|
@ -601,3 +603,17 @@ func interpolationFuncSha1() ast.Function {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func interpolationFuncSha256() ast.Function {
|
|
|
|
|
return ast.Function{
|
|
|
|
|
ArgTypes: []ast.Type{ast.TypeString},
|
|
|
|
|
ReturnType: ast.TypeString,
|
|
|
|
|
Callback: func(args []interface{}) (interface{}, error) {
|
|
|
|
|
s := args[0].(string)
|
|
|
|
|
h := sha256.New()
|
|
|
|
|
h.Write([]byte(s))
|
|
|
|
|
hash := hex.EncodeToString(h.Sum(nil))
|
|
|
|
|
return hash, nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|