Skip to content

Add color output functionality and tests for release statuses - #31032

Closed
Mazafard wants to merge 0 commit into
helm:mainfrom
Mazafard:main
Closed

Mazafard wants to merge 0 commit into
helm:mainfrom
Mazafard:main

Conversation

@Mazafard

@Mazafard Mazafard commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

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).

Key Features:

  • Automatic color support: Colors are enabled by default for interactive terminals
  • Smart TTY detection: Automatically disables colors when output is piped to files or non-interactive contexts using term.IsTerminal()
  • Opt-out mechanism: Users can disable colors using the --no-color flag or NO_COLOR environment variable
  • Targeted implementation: Adds color support to release status displays across multiple commands

Implementation Details:

  • Added a new color output module (pkg/cli/output/color.go) with functions for colorizing status, headers, and namespaces
  • Integrated --no-color flag support in the CLI environment settings
  • Added color formatting to commands: helm status, helm list, helm install, helm upgrade, helm get all, and helm test
  • Created unit tests (219 lines) to ensure color formatting works correctly
  • Uses the fatih/color library for ANSI color support

Benefits:

  • Improved readability: Visual distinction for release statuses (deployed in green, failed in red, pending in yellow)
  • Better debugging: Easier to spot issues during CI/CD or release debugging
  • Enhanced developer experience: Bold headers and colored namespaces help users quickly parse output
  • Modern CLI UX: Aligns Helm with other popular DevOps tools while maintaining backward compatibility

Special notes for your reviewer:
The current implementation provides a foundation for color support with the following color scheme:

  • Green: Deployed/successful releases
  • Red: Failed releases or unknown status
  • Yellow: Pending operations (install, upgrade, rollback, uninstalling)
  • Bold: Headers for better readability
  • Cyan: Namespaces to distinguish them from other text
  • Default: Uninstalled, superseded, and other statuses remain uncolored

The implementation respects terminal capabilities through TTY detection and honors the NO_COLOR environment variable standard. All color output can be disabled using the --no-color flag or by setting the NO_COLOR environment 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-color flag provides the necessary control for users who prefer no colors.

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 7, 2025
@Mazafard Mazafard closed this Jul 7, 2025
@pull-request-size pull-request-size Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add optional color support to Helm CLI output

1 participant