Skip to content

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

Open
LarytheLord wants to merge 1 commit intohelm:mainfrom
LarytheLord:fix/test-kubeconfig-isolation-31470
Open

test(cli): make User-Agent REST config test hermetic#31907
LarytheLord wants to merge 1 commit intohelm:mainfrom
LarytheLord:fix/test-kubeconfig-isolation-31470

Conversation

@LarytheLord
Copy link

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
Copy link
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.

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

Signed-off-by: LarytheLord <llawlietbagsum@gmail.com>
@LarytheLord LarytheLord force-pushed the fix/test-kubeconfig-isolation-31470 branch from e706b31 to 3629ef6 Compare March 6, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants