helm-diff icon indicating copy to clipboard operation
helm-diff copied to clipboard

Add --kube-context flag support to all helm-diff commands

Open Copilot opened this issue 3 months ago • 0 comments

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 string flag to all four helm-diff commands
  • The flag accepts a kubeconfig context name and passes it to underlying helm commands

Implementation Details:

  • Added kubeContext field 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 --namespace flag

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.

Copilot avatar Sep 08 '25 01:09 Copilot