Skip to content

feat: handle path list for kubeconfig env var #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ndbaker1
Copy link

@ndbaker1 ndbaker1 commented Jul 17, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR implement simple parsing of $KUBECONFIG as a path list, similar to how it is done in client-go:

this allows users to do things like pickup a directory-scoped kubeconfig as well as the home directory fallback using the following config:

KUBECONFIG=.kube/config:~/.kube/config
Testing
> go test ./klient/conf/... -v
I0719 21:52:56.402946  827913 main_test.go:71] file created successfully/home/nbakerd/test/.kube/config
=== RUN   TestResolveKubeConfigFileFlag
--- PASS: TestResolveKubeConfigFileFlag (0.00s)
=== RUN   TestResolveKubeConfigFileEnv
=== RUN   TestResolveKubeConfigFileEnv/WithEnvEmpty
=== RUN   TestResolveKubeConfigFileEnv/WithEnvPath
=== RUN   TestResolveKubeConfigFileEnv/WithEnvPathListAllExist
=== RUN   TestResolveKubeConfigFileEnv/WithEnvPathListFirstExists
=== RUN   TestResolveKubeConfigFileEnv/WithEnvPathListLastExists
=== RUN   TestResolveKubeConfigFileEnv/WithEnvPathListNoneExist
--- PASS: TestResolveKubeConfigFileEnv (0.00s)
    --- PASS: TestResolveKubeConfigFileEnv/WithEnvEmpty (0.00s)
    --- PASS: TestResolveKubeConfigFileEnv/WithEnvPath (0.00s)
    --- PASS: TestResolveKubeConfigFileEnv/WithEnvPathListAllExist (0.00s)
    --- PASS: TestResolveKubeConfigFileEnv/WithEnvPathListFirstExists (0.00s)
    --- PASS: TestResolveKubeConfigFileEnv/WithEnvPathListLastExists (0.00s)
    --- PASS: TestResolveKubeConfigFileEnv/WithEnvPathListNoneExist (0.00s)
=== RUN   TestNew
--- PASS: TestNew (0.00s)
=== RUN   TestNewWithContextName
--- PASS: TestNewWithContextName (0.00s)
PASS
ok  	sigs.k8s.io/e2e-framework/klient/conf	0.005s

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

the KUBECONFIG env var can now be provided as a list of paths

Additional documentation e.g., Usage docs, etc.:

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 17, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ndbaker1
Once this PR has been reviewed and has the lgtm label, please assign harshanarayana for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Jul 17, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @ndbaker1!

It looks like this is your first PR to kubernetes-sigs/e2e-framework 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/e2e-framework has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @ndbaker1. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 17, 2025
@ndbaker1 ndbaker1 changed the title feat: handle path list for KUBECONFIG env var feat: handle path list for kubeconfig env var Jul 17, 2025
@vladimirvivien
Copy link
Contributor

Hi @ndbaker1 thanks for this PR.
Please add the followings

  • Tests (with different scenarios) to catch regressions
  • Documentation showing how this would work.

Thanks.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 19, 2025
@ndbaker1 ndbaker1 force-pushed the pathlist branch 4 times, most recently from bcd9589 to e7f5b15 Compare July 19, 2025 21:53
@ndbaker1
Copy link
Author

thanks for looking @vladimirvivien! i added unit tests with my latest revision and improved the PR overview.
please let me know what else you recommend in terms of documentation!

Copy link
Contributor

@vladimirvivien vladimirvivien left a comment

Choose a reason for hiding this comment

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

@ndbaker1 this looks good. Please add an example markdown doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

3 participants