remove HELMFILE_SKIP_INSECURE_TEMPLATE_FUNCTIONS for v1 (#1434)
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
95e39fd821
commit
270f27f481
|
|
@ -1,15 +1,18 @@
|
||||||
package envvar
|
package envvar
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DisableInsecureFeatures = "HELMFILE_DISABLE_INSECURE_FEATURES"
|
DisableInsecureFeatures = "HELMFILE_DISABLE_INSECURE_FEATURES"
|
||||||
DisableRunnerUniqueID = "HELMFILE_DISABLE_RUNNER_UNIQUE_ID"
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
SkipInsecureTemplateFunctions = "HELMFILE_SKIP_INSECURE_TEMPLATE_FUNCTIONS"
|
SkipInsecureTemplateFunctions = "HELMFILE_SKIP_INSECURE_TEMPLATE_FUNCTIONS"
|
||||||
Experimental = "HELMFILE_EXPERIMENTAL" // environment variable for experimental features, expecting "true" lower case
|
|
||||||
Environment = "HELMFILE_ENVIRONMENT"
|
DisableRunnerUniqueID = "HELMFILE_DISABLE_RUNNER_UNIQUE_ID"
|
||||||
FilePath = "HELMFILE_FILE_PATH"
|
Experimental = "HELMFILE_EXPERIMENTAL" // environment variable for experimental features, expecting "true" lower case
|
||||||
TempDir = "HELMFILE_TEMPDIR"
|
Environment = "HELMFILE_ENVIRONMENT"
|
||||||
UpgradeNoticeDisabled = "HELMFILE_UPGRADE_NOTICE_DISABLED"
|
FilePath = "HELMFILE_FILE_PATH"
|
||||||
V1Mode = "HELMFILE_V1MODE"
|
TempDir = "HELMFILE_TEMPDIR"
|
||||||
GoccyGoYaml = "HELMFILE_GOCCY_GOYAML"
|
UpgradeNoticeDisabled = "HELMFILE_UPGRADE_NOTICE_DISABLED"
|
||||||
CacheHome = "HELMFILE_CACHE_HOME"
|
V1Mode = "HELMFILE_V1MODE"
|
||||||
|
GoccyGoYaml = "HELMFILE_GOCCY_GOYAML"
|
||||||
|
CacheHome = "HELMFILE_CACHE_HOME"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/helmfile/helmfile/pkg/envvar"
|
"github.com/helmfile/helmfile/pkg/envvar"
|
||||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||||
"github.com/helmfile/helmfile/pkg/maputil"
|
"github.com/helmfile/helmfile/pkg/maputil"
|
||||||
|
"github.com/helmfile/helmfile/pkg/runtime"
|
||||||
"github.com/helmfile/helmfile/pkg/yaml"
|
"github.com/helmfile/helmfile/pkg/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,13 +36,24 @@ func (e DisableInsecureFeaturesError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
disableInsecureFeatures bool
|
disableInsecureFeatures bool
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
skipInsecureTemplateFunctions bool
|
skipInsecureTemplateFunctions bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
disableInsecureFeatures, _ = strconv.ParseBool(os.Getenv(envvar.DisableInsecureFeatures))
|
disableInsecureFeatures, _ = strconv.ParseBool(os.Getenv(envvar.DisableInsecureFeatures))
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
skipInsecureTemplateFunctions, _ = strconv.ParseBool(os.Getenv(envvar.SkipInsecureTemplateFunctions))
|
skipInsecureTemplateFunctions, _ = strconv.ParseBool(os.Getenv(envvar.SkipInsecureTemplateFunctions))
|
||||||
|
skipInsecureTemplateFunctions = func() bool {
|
||||||
|
if runtime.V1Mode {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
b, _ := strconv.ParseBool(os.Getenv(envvar.SkipInsecureTemplateFunctions))
|
||||||
|
return b
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) createFuncMap() template.FuncMap {
|
func (c *Context) createFuncMap() template.FuncMap {
|
||||||
|
|
@ -86,6 +98,9 @@ func (c *Context) createFuncMap() template.FuncMap {
|
||||||
funcMap["exec"] = func(string, []any, ...string) (string, error) {
|
funcMap["exec"] = func(string, []any, ...string) (string, error) {
|
||||||
return "", DisableInsecureFeaturesErr
|
return "", DisableInsecureFeaturesErr
|
||||||
}
|
}
|
||||||
|
funcMap["envExec"] = func(map[string]any, string, []any, ...string) (string, error) {
|
||||||
|
return "", DisableInsecureFeaturesErr
|
||||||
|
}
|
||||||
funcMap["readFile"] = func(string) (string, error) {
|
funcMap["readFile"] = func(string) (string, error) {
|
||||||
return "", DisableInsecureFeaturesErr
|
return "", DisableInsecureFeaturesErr
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,12 @@ func TestCreateFuncMap_DisabledInsecureFeatures(t *testing.T) {
|
||||||
disableInsecureFeatures = currentVal
|
disableInsecureFeatures = currentVal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this function once Helmfile v0.x
|
||||||
func TestCreateFuncMap_SkipInsecureTemplateFunctions(t *testing.T) {
|
func TestCreateFuncMap_SkipInsecureTemplateFunctions(t *testing.T) {
|
||||||
|
if runtime.V1Mode {
|
||||||
|
t.Logf("SkipInsecureTemplateFunctions is not supported in V1 mode")
|
||||||
|
return
|
||||||
|
}
|
||||||
currentVal := skipInsecureTemplateFunctions
|
currentVal := skipInsecureTemplateFunctions
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue