helmfile/cmd
Dominik Schmidt 33eadc993e
feat: support HELMFILE_* env vars for more global flags (#2606)
* feat: support more HELMFILE_* env vars as flag fallbacks

Adds env-var fallbacks for global flags, mirroring the existing
HELMFILE_ENVIRONMENT / HELMFILE_KUBE_CONTEXT pattern:

* --helm-binary       -> HELMFILE_HELM_BINARY
* --kustomize-binary  -> HELMFILE_KUSTOMIZE_BINARY
* --log-level         -> HELMFILE_LOG_LEVEL
* --debug             -> HELMFILE_DEBUG       (expecting "true" lower case)
* --quiet             -> HELMFILE_QUIET       (expecting "true" lower case)
* --no-color          -> HELMFILE_NO_COLOR    (expecting "true" lower case),
                         additionally honors NO_COLOR per no-color.org
                         (any non-empty value disables color)

Flag values still take precedence; env vars are consulted only when the
flag is unset. The string-flag default values ("helm", "kustomize",
"info") move into the accessor methods so the env-var fallback can
actually trigger when no flag is passed.

Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de>

* docs: mention new HELMFILE_* env vars in cli.md and templating.md

Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de>

* fix: make Color/NoColor/env interaction consistent

Two issues with the env-aware NoColor() introduced together with
HELMFILE_NO_COLOR / NO_COLOR support:

1. Color() consulted the raw GlobalOptions.NoColor field instead of
   NoColor(), so in a TTY with only the env set, Color() fell through
   to terminal autodetect and ValidateConfig() spuriously errored with
   "--color and --no-color cannot be specified at the same time".

2. NoColor() returned true via env even when --color was explicitly
   passed, so `helmfile --color` with NO_COLOR (or HELMFILE_NO_COLOR=true)
   in the environment hit the same ValidateConfig() error. A flag should
   always win over an env var.

Fix both by routing Color() through NoColor() and giving NoColor() an
explicit --color short-circuit. Regression tests added for both paths.

Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de>

---------

Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de>
2026-05-22 09:16:52 +08:00
..
apply.go fix: add trackFailOnError option to control kubedog exit code (#2576) 2026-05-04 14:20:03 +08:00
build.go Optimize cmd pkg (#384) 2022-10-05 11:02:24 +09:00
cache.go Merge branch 'main' into update_golang_lint 2022-08-14 12:21:10 +09:00
create.go feat: add 'create' subcommand to scaffold helmfile deployment projects (#2574) 2026-05-03 19:03:11 +08:00
deps.go fix --debug flag 2022-10-25 08:24:23 +08:00
destroy.go Create DeleteWait and DeleteTimeout parameters for Destroy (#1177) 2023-12-05 08:38:37 +08:00
diff.go Issue-1883 fix (#2058) 2025-11-19 07:45:56 +08:00
fetch.go feat: add --write-output flag to helmfile fetch for air-gapped environments (#2572) 2026-05-03 18:32:30 +08:00
init.go Add subcommand init for checks and installs helmfile deps (#389) 2022-11-03 14:51:30 +08:00
lint.go feat: add/expose cli flags (#771) 2023-04-02 14:53:52 +08:00
list.go Optimize cmd pkg (#384) 2022-10-05 11:02:24 +09:00
print_env.go feat: add print-env command (#2279) 2025-11-28 08:46:37 +08:00
repos.go fix: repos command help message (#698) 2023-02-15 07:23:50 +08:00
root.go feat: support HELMFILE_* env vars for more global flags (#2606) 2026-05-22 09:16:52 +08:00
root_test.go fix: prevent panic in helmfile init on plugin install errors (#2401) 2026-02-18 08:57:11 +08:00
show-dag.go Update DAG with dependencies (#1477) 2024-04-27 07:37:28 +08:00
status.go fix --debug flag 2022-10-25 08:24:23 +08:00
sync.go feat: show diff preview when sync --interactive is used (#2603) 2026-05-21 20:47:00 +08:00
template.go feat: support .Environment.* in --output-dir-template (#2375) 2026-02-14 11:54:43 +08:00
test.go feat: add/expose cli flags (#771) 2023-04-02 14:53:52 +08:00
unittest.go feat: add `helmfile unittest` command for helm-unittest integration (#2400) 2026-02-16 09:45:10 +08:00
write-values.go feat: add/expose cli flags (#771) 2023-04-02 14:53:52 +08:00