Bug 2024427 - oc completion zsh doesn't auto complete
Summary: oc completion zsh doesn't auto complete
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.9
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.11.0
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard: LifecycleStale
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-18 04:09 UTC by Alan Chan
Modified: 2022-08-10 10:40 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-08-10 10:39:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 6896731 0 None None None 2022-04-20 09:02:35 UTC
Red Hat Product Errata RHSA-2022:5069 0 None None None 2022-08-10 10:40:25 UTC

Description Alan Chan 2021-11-18 04:09:38 UTC
Description of problem:

- oc completion zsh doesn't auto complete


Version-Release number of selected component (if applicable):

- Appears to on all 4.9.z versions, tested on both macos and linux. 


How reproducible:

- Always


The issue:

- Because of the first couple lines of the completion shell script appear to be incorrect:

---
[root@node-0]~# oc completion zsh | head
#compdef kubectl
compdef _kubectl kubectl

#compdef _oc oc

# zsh completion for oc                                   -*- shell-script -*-

__oc_debug()
{
    local file="$BASH_COMP_DEBUG_FILE"
---

The first two lines should probably be these instead:

---
#compdef oc
compdef _oc oc
---

This is likely because the possible inheritance of the previous versions (<4.9) of oc completion which include kubectl definition.

Comment 1 Michal Fojtik 2021-12-25 04:22:29 UTC
This bug hasn't had any activity in the last 30 days. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're marking this bug as "LifecycleStale" and decreasing the severity/priority. If you have further information on the current state of the bug, please update it, otherwise this bug can be closed in about 7 days. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. Additionally, you can add LifecycleFrozen into Whiteboard if you think this bug should never be marked as stale. Please consult with bug assignee before you do that.

Comment 3 Paul Barfuss 2022-01-18 19:48:12 UTC
Hey there, this should be fixed upstream now in the following PR and issue:
https://github.com/kubernetes/kubernetes/issues/106968
https://github.com/kubernetes/kubernetes/pull/106969

The issue is still open in the oc repo as it looks to be going into v1.24:
https://github.com/openshift/oc/issues/968

Info on the v1.24 milestone can be found at https://github.com/kubernetes/kubernetes/milestone/57

At one point I opened a PR to unwrap "oc completion" but did not think it would be necessary as there is a pretty simple workaround people can use in the meantime using sed to replace kubectl with oc:

# Load the oc completion code for zsh[1] into the current shell
source <(oc completion zsh | sed -e 's/kubectl/oc/g')
# Set the oc completion code for zsh[1] to autoload on startup
oc completion zsh | sed -e 's/kubectl/oc/g' > "${fpath[1]}/_oc"

Comment 6 Maciej Szulik 2022-04-01 13:38:27 UTC
This should be fixed as soon as we pull in 1.24 into oc.

Comment 7 Maciej Szulik 2022-04-01 13:43:05 UTC
In the mean time I opened 1.23 cherry-pick which will allow us to get that in updated oc in 4.10 https://github.com/kubernetes/kubernetes/pull/109235

Comment 9 Maciej Szulik 2022-05-31 11:29:54 UTC
1.24 landed in https://github.com/openshift/oc/pull/1092

Comment 11 zhou ying 2022-06-01 05:56:21 UTC
[root@localhost ~]#  oc version 
Client Version: 4.11.0-0.nightly-2022-05-26-013101
Kustomize Version: v4.5.4



[root@localhost ~]# oc completion zsh |head
#compdef oc
compdef _oc oc

#compdef _oc oc

# zsh completion for oc                                   -*- shell-script -*-

__oc_debug()
{
    local file="$BASH_COMP_DEBUG_FILE"

Comment 15 errata-xmlrpc 2022-08-10 10:39:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Container Platform 4.11.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5069


Note You need to log in before you can comment on or make changes to this bug.