kubectx icon indicating copy to clipboard operation
kubectx copied to clipboard

Added hability to switch to a context using a partial name

Open jordiprats opened this issue 4 years ago • 7 comments

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

jordiprats avatar Nov 15 '21 19:11 jordiprats

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
Corporate signers

ℹ️ Googlers: Go here for more info.

googlebot avatar Nov 15 '21 19:11 googlebot

@googlebot I signed it!

jordiprats avatar Nov 15 '21 19:11 jordiprats

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

googlebot avatar Nov 15 '21 19:11 googlebot

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.

ahmetb avatar Nov 15 '21 19:11 ahmetb

Would it be this accepted if I add this as a flag?

For example:

kubectl ctx -s example

jordiprats avatar Nov 15 '21 19:11 jordiprats

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.

ahmetb avatar Nov 15 '21 19:11 ahmetb

Sure, thank you for your feedback. I don't really like it to be interactive, that's why I have proposed this

jordiprats avatar Nov 15 '21 20:11 jordiprats