mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 13:44:57 +02:00
feat: Helmfile V1 mode (#594)
* feat: Helmfile V1 mode We add a new "V1 mode" to Helmfile so that you can seemlessly upgrade Helmfile from the current v0.x to the upcoming v1.0. The idea is that we build both v0 and v1 binaries from the same tagged commit within the main branch, with different defaults for the "V1 mode"- the V1 mode is disabled by default for v0.x binaries, while it is enabled by default for v1.x binaries. The V1 mode can be overrode at runtime via envvar. That is, even after upgrading the binary to v1, you will not see any backward-incompatible changes while you explicitly set an envvar, `HELMFILE_V1MODE=true`, at runtime. Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/envvar"
|
||||
)
|
||||
|
||||
// V1Mode is false by default for Helmfile v0.x and
|
||||
// true by default for Helmfile v1.x
|
||||
var (
|
||||
V1Mode 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)
|
||||
}
|
||||
|
||||
func init() {
|
||||
// You can toggle the V1 mode at runtime via an envvar:
|
||||
// - Helmfile v1.x behaves like v0.x by running it with HELMFILE_V1MODE=false
|
||||
// - Helmfile v0.x behaves like v1.x by with HELMFILE_V1MODE=true
|
||||
switch os.Getenv(envvar.V1Mode) {
|
||||
case "true":
|
||||
V1Mode = true
|
||||
case "false":
|
||||
V1Mode = false
|
||||
default:
|
||||
V1Mode, _ = strconv.ParseBool(v1Mode)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user