Added hability to switch to a context using a partial name
This PR is to be able to switch to the context if only one matches. This is intended for EKS clusters where the default context name is the ARN (arn:aws:eks:REGION:ACCOUNTNUMBER:cluster/CLUSTERNAME) which is quite long but includes the cluster name
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
ℹ️ Googlers: Go here for more info.
@googlebot I signed it!
This did come up in the past and I think (1) it's kinda dangerous as that might not always be the intent and might switch into an unintended context, especially in a non-interactive setting (2) fzf has a builtin flag/feature that does this (I believe "--select-1") (3) we are accepting new changes to the Go implementation at this point (4) there's #324 adding this (with fzf support). That's why I'm inclined to not pursue this.
Would it be this accepted if I add this as a flag?
For example:
kubectl ctx -s example
I think the fzf support already is going to offer this in the PR I linked so I don't think this should be a separate option like -s.
Something like this makes sense only in the interactive context (i.e. not from a script) and in that scenario, we already have a fuzzy search integration with fzf for a long time now and we'll add tools like sk as well (there's an open issue on that too).
So I am inclined to not accept this as a new option or to the bash script. The bash based script is rather small and static , feel free to maintain your fork.
Sure, thank you for your feedback. I don't really like it to be interactive, that's why I have proposed this