mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 07:21:03 +02:00
Use gopkg.in/yaml.v2 for Helmfile v0.x (#609)
This should fix #435 for Helmfile v0.x releases since the next v0.150.0. We introduce a new envvar to opt-in to the new YAML library, so that you can give it a shot before upgrading your Helmfile to v1. The same envvar can be used to opt-out of the new YAML library after you upgrade to Helmfile v1, giving you a more flexible migration story. Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
+21
-1
@@ -13,13 +13,23 @@ import (
|
||||
var (
|
||||
V1Mode bool
|
||||
|
||||
// GoccyGoYaml is set to true in order to let Helmfile use
|
||||
// goccy/go-yaml instead of gopkg.in/yaml.v2.
|
||||
// It's false by default in Helmfile v0.x and true by default for Helmfile v1.x.
|
||||
GoccyGoYaml bool
|
||||
|
||||
// We set this via ldflags at build-time so that we can use the
|
||||
// value specified at the build time as the runtime default.
|
||||
v1Mode string
|
||||
)
|
||||
|
||||
func Info() string {
|
||||
return fmt.Sprintf("V1 mode = %v", V1Mode)
|
||||
yamlLib := "gopkg.in/yaml.v2"
|
||||
if GoccyGoYaml {
|
||||
yamlLib = "goccy/go-yaml"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("V1 mode = %v\nYAML library = %v", V1Mode, yamlLib)
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -34,4 +44,14 @@ func init() {
|
||||
default:
|
||||
V1Mode, _ = strconv.ParseBool(v1Mode)
|
||||
}
|
||||
|
||||
// You can switch the YAML library at runtime via an envvar:
|
||||
switch os.Getenv(envvar.GoccyGoYaml) {
|
||||
case "true":
|
||||
GoccyGoYaml = true
|
||||
case "false":
|
||||
GoccyGoYaml = false
|
||||
default:
|
||||
GoccyGoYaml = V1Mode
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user