Merge pull request 'add template func get_keystore_secret' (#113) from alert_keystore into master

This commit is contained in:
silenceqi 2023-06-05 15:12:34 +08:00
commit 161b44017a
2 changed files with 20 additions and 0 deletions

View File

@ -32,4 +32,5 @@ var genericMap = map[string]interface{}{
"div": div,
"mul": mul,
"lookup": lookup,
"get_keystore_secret": getKeystoreSecret,
}

View File

@ -0,0 +1,19 @@
/* Copyright © INFINI Ltd. All rights reserved.
* Web: https://infinilabs.com
* Email: hello#infini.ltd */
package funcs
import (
log "github.com/cihub/seelog"
"infini.sh/framework/core/keystore"
)
func getKeystoreSecret(key string) string {
vBytes, err := keystore.GetValue(key)
if err != nil {
log.Error("retrieve secret error: ", err)
return "N/A"
}
return string(vBytes)
}