Repository navigation
Feat: Add color output functionality and tests for release statuses - #31034
Conversation
Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
|
So, first thing thank you for the PR. I have a questions to the other maintainers on |
gjenkins8
left a comment
There was a problem hiding this comment.
Some initial comments.
Requesting change to make the output package internal (unless there is a very good reason we think it should be public?)
Loosely held opinion -- I think off by default, until the majority of Helm commands support colorized output. |
Thank you for the review @gjenkins8 , Could you clarify what you mean by making the package public? The output package was already public. I just added functions to it since it seemed like the most relevant place for output-related code. |
Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
…ntrol Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
…rEnabled method Signed-off-by: Mohammadreza Asadollahifard <[email protected]>
|
@gjenkins8 @joejulian @robertsirc Would you mind taking a look when you get a chance? |
|
thanks! |
closes #31031
What this PR does / why we need it:
This PR introduces ANSI color support to Helm CLI output to improve human readability and align Helm with modern CLI UX practices. The implementation addresses the feature request in #31031 for colorful CLI output, which is now standard in many popular DevOps tools (e.g., kubectl, docker, git, terraform).
Note: This is a clean resubmission of PR #31032 which was closed due to merge conflicts with the main branch. This PR contains the same functionality but is properly rebased on the latest upstream/main.
Key Features:
term.IsTerminal()--no-colorflag orNO_COLORenvironment variableImplementation Details:
pkg/cli/output/color.go) with functions for colorizing status, headers, and namespaces--no-colorflag support in the CLI environment settingshelm status,helm list,helm install,helm upgrade,helm get all, andhelm testfatih/colorlibrary for ANSI color supportColorEnabled()function to clean up the codebaseBenefits:
Special notes for your reviewer:
The current implementation provides a foundation for color support with the following color scheme:
The implementation respects terminal capabilities through TTY detection and honors the
NO_COLORenvironment variable standard. All color output can be disabled using the--no-colorflag or by setting theNO_COLORenvironment variable, ensuring full backward compatibility for automation and scripting use cases.Note: While issue #31031 mentioned opt-in colors (disabled by default), this implementation enables colors by default for interactive terminals, following the pattern of modern CLI tools. The opt-out mechanism via
--no-colorflag provides the necessary control for users who prefer no colors.Updated based on review feedback: Changed the default color mode from "never" to "auto" to enable colors by default for interactive terminals, following team consensus for the v4 release.
Changes Made
New Files:
pkg/cli/output/color.go- Color formatting functionspkg/cli/output/color_test.go- Comprehensive unit testsModified Files:
pkg/cli/environment.go- AddedColorModefield,--colorflag support, andenvColorMode()functionColorEnabled()functioncmd/helm/status.go- Colorized status outputcmd/helm/list.go- Colorized list outputcmd/helm/install.go- Colorized install statuscmd/helm/upgrade.go- Colorized upgrade statuscmd/helm/get_all.go- Colorized get all outputcmd/helm/release_testing.go- Colorized test resultsAdditional Fixes:
os.Setenv()witht.Setenv()in test files to comply with golangci-lint recommendationsusetestinglinter warnings for better test isolationIf applicable:
docs neededlabel should be applied if so)Testing
NO_COLORenvironment variableHELM_COLORenvironment variable (never/auto/always)--colorflag with all values (never/auto/always)