oc: `oc` completion not working despite running the required command `oc completion zsh` or saving output to zsh `fpath`
Not understanding why my oc completion isn’t working despite all of my other completions working perfectly in zsh environment. Downloaded the latest binary for oc and have it installed in my /usr/local/bin/ space and then trying the following scenarios with zero luck:
source [<oc completion zsh) and saving that in .zshrc with no success.
or simply saving the output to my fpath custom location along with all of my other completions such as kubectl which work fine.
oc completion zsh > ~/.oh-my-zsh/completions/_oc
After running any of the above I still get nothing for tab completion against oc.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
There are a couple of other workarounds for this, such as downgrading your client for the
oc completion zshcommand, or replacing doing as/kubectl/oc/as a one-liner.Linking related upstream issue/PR with possibly a simpler solution that unwrapping the
oc completioncommand.Upstream issue: https://github.com/kubernetes/kubernetes/issues/106968 Upstream PR: https://github.com/kubernetes/kubernetes/pull/106969
It looks like the upstream fix is just waiting on a final approval.
the
kubectlcompletion works fine onzshbut it appears the add linecompdef kubectl _kubectlbreaks theoccompletion starting fromrelease-4.8this is my fix
it appears that on
v1.20.2the code is different https://github.com/kubernetes/kubectl/blob/release-1.20/pkg/cmd/completion/completion.go#L146this change was from
Kubernetesversionv1.22https://github.com/kubernetes/kubectl/blob/release-1.22/pkg/cmd/completion/completion.go#L152@eifrach It appears https://github.com/openshift/oc/blob/master/contrib/completions/zsh/oc is just a generated file for testing purposes and not a template. The
oc completioncommand is just a wrapper forkubectl completionso the issue is going to be a change upstream to how this command produces the zsh completions and would not be as simple as fixing the generated file.It looks like the
compdef kubectl _kubectlline is now being hardcoded in the upstreamkubectl completion zshfunction:https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/completion/completion.go#L173