Repository navigation
Conversation
Helm 4 has a global --color flag that takes never, auto or always. It parses that flag from the whole command line before it starts a plugin, and hands a --color=<mode> it accepted on to the plugin unchanged. helm-diff then failed, because its --color only took a bool: $ helm diff upgrade --color=always my-release ./chart Error: invalid argument "always" for "--color" flag: strconv.ParseBool: parsing "always": invalid syntax The same happened with Helm's own `helm --color=never diff ...`. A bare --color followed by another argument never reaches helm-diff on Helm 4: Helm reads that argument as the mode and rejects it. Let --color also take always, never and auto. It still works without a value and with true or false. Document the Helm 4 behaviour in the README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #880
Problem
Helm 4 added a global
--colorflag that takesnever,autooralways. Helm parses it from the whole command line before it starts a plugin (newRootCmdWithConfiginpkg/cmd/root.go) and then hands the arguments to the plugin unchanged. With Helm v4.3.2 (helm diff upgrade --dry-run ... rel ./chart):--color -f values.yamlinvalid color mode "-f": must be one of: never, auto, always--color=trueinvalid color mode "true"--color=alwaysError: invalid argument "always" for "--color" flag: strconv.ParseBool: parsing "always": invalid syntax--color=never,helm --color=never diff upgrade ...Error: invalid argument "never" for "--color" flag: ...--color=autoError: invalid argument "auto" for "--color" flag: ...--coloras the last argumentSo on Helm 4 the only way to force colors from the command line was a bare
--colorat the very end, where Helm ignores its own parse error.Fix
--colornow also takesalways,neverandauto. A bare--color,--color=trueand--color=falsebehave as before, so nothing changes with Helm 3.autofalls back to the terminal check that runs when no color flag is given. The flag still shows as a switch in--help, so only its usage text changes in the README tables. The README gets a short section on how Helm 4 reads--color.--color alwayswith a space still fails:--colorhas to keep working without a value, so the next argument is never read as its value (as with--dry-run=server). The exact command from #880 (--color -f values.yaml) is rejected by Helm itself before helm-diff runs, and Helm 4 does not pass the mode it parsed to plugins in any other way, so that form can only be documented here.Tests
TestColorFlagrunsversionwith each form of the flag and checks the ansi and bunt color state, plus the error for an unknown value; on master it fails foralways,neverandauto.go test ./cmd/,make lintandmake verify-readmepass. The table was run offline against the plugin built from master and from this branch.