mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 19:28:51 +00:00
fix: make initialization a standalone process to account for concurrent calls
This commit is contained in:
@@ -6,8 +6,6 @@ import (
|
|||||||
"github.com/Masterminds/sprig/v3"
|
"github.com/Masterminds/sprig/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var initialized = false
|
|
||||||
|
|
||||||
var customInfisicalSecretTemplateFunctions = tpl.FuncMap{
|
var customInfisicalSecretTemplateFunctions = tpl.FuncMap{
|
||||||
"pkcs12key": pkcs12key,
|
"pkcs12key": pkcs12key,
|
||||||
"pkcs12keyPass": pkcs12keyPass,
|
"pkcs12keyPass": pkcs12keyPass,
|
||||||
@@ -45,12 +43,7 @@ const (
|
|||||||
pemTypeKey = "PRIVATE KEY"
|
pemTypeKey = "PRIVATE KEY"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetTemplateFunctions() tpl.FuncMap {
|
func InitializeTemplateFunctions() {
|
||||||
// we don't want to run this whole function every time because it's expensive, so we cache the result after the first run
|
|
||||||
if initialized {
|
|
||||||
return customInfisicalSecretTemplateFunctions
|
|
||||||
}
|
|
||||||
|
|
||||||
templates := customInfisicalSecretTemplateFunctions
|
templates := customInfisicalSecretTemplateFunctions
|
||||||
|
|
||||||
sprigFuncs := sprig.TxtFuncMap()
|
sprigFuncs := sprig.TxtFuncMap()
|
||||||
@@ -67,7 +60,8 @@ func GetTemplateFunctions() tpl.FuncMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
customInfisicalSecretTemplateFunctions = templates
|
customInfisicalSecretTemplateFunctions = templates
|
||||||
initialized = true
|
}
|
||||||
|
|
||||||
return templates
|
func GetTemplateFunctions() tpl.FuncMap {
|
||||||
|
return customInfisicalSecretTemplateFunctions
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user