feat: add HELMFILE_INTERACTIVE env var to enable interactive mode (#1787)

* feat: add HELMFILE_INTERACTIVE env var to enable interactive mode

This commit adds the `HELMFILE_INTERACTIVE` environment variable
to enable the interactive mode by default.
Anything other than `true` will disable the interactive mode.
The precedence has the `--interactive` flag.

Signed-off-by: Krzysztof Łuczak <krzysztof.luczak.pro@gmail.com>

* Trim trailing whitespaces

Signed-off-by: Krzysztof Łuczak <krzysztof.luczak.pro@gmail.com>

---------

Signed-off-by: Krzysztof Łuczak <krzysztof.luczak.pro@gmail.com>
This commit is contained in:
Krzysztof Łuczak 2024-11-18 09:35:48 +01:00 committed by GitHub
parent 0b1746bdf3
commit 4287471acc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View File

@ -551,6 +551,7 @@ Helmfile uses some OS environment variables to override default behaviour:
* `HELMFILE_GOCCY_GOYAML` - 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.
* `HELMFILE_CACHE_HOME` - specify directory to store cached files for remote operations
* `HELMFILE_FILE_PATH` - specify the path to the helmfile.yaml file
* `HELMFILE_INTERACTIVE` - enable interactive mode, expecting `true` lower case. The same as `--interactive` CLI flag
## CLI Reference
@ -1657,6 +1658,9 @@ Use it when you're running `helmfile` manually on your local machine or a kind o
For your local use-case, aliasing it like `alias hi='helmfile --interactive'` would be convenient.
Another way to use it is to set the environment variable `HELMFILE_INTERACTIVE=true` to enable the interactive mode by default.
Anything other than `true` will disable the interactive mode. The precedence has the `--interactive` flag.
## Running Helmfile without an Internet connection
Once you download all required charts into your machine, you can run `helmfile sync --skip-deps` to deploy your apps.

View File

@ -246,7 +246,10 @@ func (g *GlobalImpl) ValidateConfig() error {
// Interactive returns the Interactive
func (g *GlobalImpl) Interactive() bool {
return g.GlobalOptions.Interactive
if g.GlobalOptions.Interactive {
return true
}
return os.Getenv(envvar.Interactive) == "true"
}
// Args returns the args to use for helm

View File

@ -18,4 +18,5 @@ const (
V1Mode = "HELMFILE_V1MODE"
GoccyGoYaml = "HELMFILE_GOCCY_GOYAML"
CacheHome = "HELMFILE_CACHE_HOME"
Interactive = "HELMFILE_INTERACTIVE"
)