Open PascalVA opened 4 years ago
We actually don’t need cobra. We’ll just update the comp scripts to get ctxs ns’es from kubectl, it would be the fastest. We’ll probably do this while switching to Go implementation as the primary distribution (it is not, yet).
I think I might have incorrectly expressed my request. I was actually talking about the go binary outputting the completions instead of having different files for it in the repository that we would have to copy in order to be able to source the completions.
Got it. I don't exactly follow the benefits of that. When it's a file, it will almost always be read faster. When it's coming from a program, it's susceptible to startup time of the program.
Our go implementations start up fast right now, but if you do time kubectl completion bash
you'll notice 70ms-1170ms based on attempts on my machine. We’d in no way want to slow down the shell startup like kubectl does.
But if as you said we can print the comp scripts very fast somehow, we could do that. That said, this is not a problem for people using package managers (brew, apk etc) since those already know where to place the comp files without the user having to source <(kubectx completion)
in their bashrc/zshrc files.
Yeah, I suppose that the shell startup time could be an issue. 1170ms is quite a long time (kubectl is huge though). It would just be nice to have the option to not put the files in the completion dirs manually.
I have a small script that generates a new subshell for running kubectl commands that includes kubens and kubectx (the go one at the moment) and the problem is that the kubectx/kubens versions are not always the same between users using this script.
i'd love this ass well.
It would be nice to have the completions built in to the go binary so we can source it in the following manner:
It would make it a lot more portable, instead of having to copy the completion files around manually. The cobra framework implements this by default if I am not mistaken.
(https://github.com/ahmetb/kubectx/issues/115#issuecomment-451455859)