Skip to content

refactor(cli): decouple EnvSettings from pkg/kube to avoid import cycles#31970

Open
isumitsolanki wants to merge 2 commits intohelm:mainfrom
isumitsolanki:fix/31965-decouple-cli-from-kube
Open

refactor(cli): decouple EnvSettings from pkg/kube to avoid import cycles#31970
isumitsolanki wants to merge 2 commits intohelm:mainfrom
isumitsolanki:fix/31965-decouple-cli-from-kube

Conversation

@isumitsolanki
Copy link
Copy Markdown

closes #31965

What this PR does / why we need it:
This PR decouples pkg/cli from pkg/kube in the EnvSettings code path to prevent import cycles for Helm library consumers.

Today, pkg/cli/environment.go imports pkg/kube only to use RetryingRoundTripper. That import pulls in a larger dependency chain and can create cycles for consumers (for example, the kustomize integration described in #31965) when importing Helm packages that depend on pkg/cli.

To fix this, the retrying round-tripper logic used by EnvSettings is moved into pkg/cli, and the pkg/cli -> pkg/kube import edge is removed. Behavior is preserved; this is a dependency-graph refactor, not a functional change.

Special notes for your reviewer:
Scope is intentionally minimal and focused on import decoupling.
Retry behavior for transient Kubernetes API server errors remains the same.
No public API signatures were changed.
Files changed:
pkg/cli/environment.go
pkg/cli/roundtripper.go

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

Move the retrying round tripper used by EnvSettings into pkg/cli so
pkg/cli no longer imports pkg/kube. This preserves retry behavior while
breaking the import edge that triggers cycles for Helm library consumers
(such as the kustomize integration described in helm#31965).

Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
Copilot AI review requested due to automatic review settings March 26, 2026 15:20
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors pkg/cli.EnvSettings to remove its dependency on pkg/kube, preventing import cycles for Helm-as-a-library consumers while preserving the existing retry behavior for transient Kubernetes API server errors.

Changes:

  • Add a pkg/cli-local retrying http.RoundTripper implementation.
  • Update EnvSettings REST config wrapping to use the new pkg/cli round-tripper and drop the pkg/kube import.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/cli/environment.go Removes pkg/kube dependency by switching the REST config wrapper to a pkg/cli-local round-tripper.
pkg/cli/roundtripper.go Introduces the retrying round-tripper implementation previously sourced from pkg/kube.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Move the retrying HTTP round-tripper used by EnvSettings into pkg/cli so
pkg/cli no longer imports pkg/kube, avoiding import cycles for Helm
library consumers while preserving retry behavior for transient API
server errors.

Add pkg/cli/roundtripper_test.go with parity coverage for the moved logic.

Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
Made-with: Cursor
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decouple pkg/cli from pkg/kube to avoid import cycles for library consumers

2 participants