Add --kube-context flag support to all helm-diff commands
This PR implements support for the --kube-context flag across all helm-diff commands (upgrade, release, revision, rollback), providing a clean alternative to the existing HELM_KUBECONTEXT environment variable workaround.
Changes Made
Command Support:
- Added
--kube-context stringflag to all four helm-diff commands - The flag accepts a kubeconfig context name and passes it to underlying helm commands
Implementation Details:
- Added
kubeContextfield to all command structs (diffCmd,release,revision,rollback) - Updated all helm command execution functions to accept and pass the kube-context parameter:
getRelease(),getHooks(),getRevision(),getChart(),template(),writeExistingValues()
- Follows the same implementation pattern as the existing
--namespaceflag
Usage Examples:
# Use specific kubeconfig context for upgrade
helm diff upgrade my-release stable/postgresql --kube-context production
# Works with all commands
helm diff release prod-release stage-release --kube-context staging
helm diff revision my-release 1 2 --kube-context development
helm diff rollback my-release 5 --kube-context production
Testing:
- Added comprehensive unit tests to verify flag functionality
- Integration tested to confirm kube-context is properly passed to helm subcommands
- All existing tests continue to pass
Documentation:
- Updated README.md with flag documentation and usage example
- Added flag to the alphabetically ordered flags list
This enhancement improves discoverability and provides a consistent interface that matches standard helm command behavior, while maintaining backward compatibility with the existing HELM_KUBECONTEXT environment variable.
Fixes #603.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.