add template func get_keystore_secret

This commit is contained in:
liugq 2023-06-05 15:09:14 +08:00
parent ffde139506
commit 64b8d4481b
2 changed files with 20 additions and 0 deletions

View File

@ -32,4 +32,5 @@ var genericMap = map[string]interface{}{
"div": div, "div": div,
"mul": mul, "mul": mul,
"lookup": lookup, "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)
}