Skip to content

test(cli): make User-Agent REST config test hermetic - #31907

Merged
mattfarina merged 3 commits into
helm:mainfrom
LarytheLord:fix/test-kubeconfig-isolation-31470
Jul 21, 2026
Merged

test(cli): make User-Agent REST config test hermetic#31907
mattfarina merged 3 commits into
helm:mainfrom
LarytheLord:fix/test-kubeconfig-isolation-31470

Conversation

@LarytheLord

Copy link
Copy Markdown
Contributor

Closes #31470

Summary

TestUserAgentHeaderInK8sRESTClientConfig currently depends on the machine's kubeconfig state. If the host has an invalid ~/.kube/config (or invalid current context), the test fails for reasons unrelated to what the test is validating.

What changed

  • Updated pkg/cli/environment_test.go to create a temporary minimal kubeconfig inside the test.
  • Set KUBECONFIG to that temporary file before calling ToRESTConfig().

Result

The test now validates only what it is meant to validate (the User-Agent wiring), and no longer depends on host-specific Kubernetes environment.

Notes

I could not run local go test in this environment because Go is not installed and Docker daemon is unavailable. CI should run the full test suite.

Copilot AI review requested due to automatic review settings March 5, 2026 18:17
@pull-request-size pull-request-size Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@LarytheLord
LarytheLord force-pushed the fix/test-kubeconfig-isolation-31470 branch from e706b31 to 3629ef6 Compare March 6, 2026 14:46
@TerryHowe
TerryHowe requested a review from Copilot March 7, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


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

Comment thread pkg/cli/environment_test.go Outdated
@pull-request-size pull-request-size Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 8, 2026
@LarytheLord

Copy link
Copy Markdown
Contributor Author

Applied the cleanup-order fix from review in pkg/cli/environment_test.go:

  • replaced defer resetEnv()() with t.Cleanup(resetEnv()) in the affected tests, so environment restoration runs after t.Setenv cleanups.

Validation run locally:

  • go test ./pkg/cli -run 'TestEnvSettings|TestUserAgentHeaderInK8sRESTClientConfig'

@LarytheLord
LarytheLord force-pushed the fix/test-kubeconfig-isolation-31470 branch from 53e8fe1 to 47d2353 Compare March 8, 2026 13:02
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

This pull request has been marked as stale because it has been open for 90 days with no activity. This pull request will be automatically closed in 30 days if no further activity occurs.

@github-actions github-actions Bot added the Stale label Jun 7, 2026

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

TerryHowe
TerryHowe previously approved these changes Jun 8, 2026

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe TerryHowe added Has One Approval This PR has one approval. It still needs a second approval to be merged. and removed Stale labels Jun 8, 2026
gjenkins8
gjenkins8 previously approved these changes Jun 18, 2026

@gjenkins8 gjenkins8 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for the change. could you e.g. rebase to re-run CI please

@gjenkins8 gjenkins8 added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 23, 2026
Signed-off-by: LarytheLord <llawlietbagsum@gmail.com>
Signed-off-by: LarytheLord <llawlietbagsum@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 10:10
@LarytheLord
LarytheLord dismissed stale reviews from gjenkins8 and TerryHowe via 47bde11 July 6, 2026 10:10
@LarytheLord
LarytheLord force-pushed the fix/test-kubeconfig-isolation-31470 branch from 47d2353 to 47bde11 Compare July 6, 2026 10:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread pkg/cli/environment_test.go Outdated
@TerryHowe TerryHowe closed this Jul 18, 2026
@TerryHowe TerryHowe reopened this Jul 18, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
Copilot AI review requested due to automatic review settings July 18, 2026 11:33
@pull-request-size pull-request-size Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe TerryHowe removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 18, 2026

@mattfarina mattfarina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@mattfarina
mattfarina merged commit 29cdf6b into helm:main Jul 21, 2026
5 checks passed
@mattfarina mattfarina added this to the 4.3.0 milestone Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has One Approval This PR has one approval. It still needs a second approval to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestUserAgentHeaderInK8sRESTClientConfig appears to fail when you have a bad .kube/config

5 participants