kubernetes: Kubectl bash completion doesn't properly handle namespace flag
The kubectl bash completion doesn’t take into account the namespace flag, and instead completes as if the flag wasn’t passed.
Without namespace works correctly:
$ kubectl get service k
kibana kubernetes
With namespace, ignores it and completes as in the first case:
$ kubectl get service --namespace=kube-system k
kibana kubernetes
It should instead complete using the services I have in that namespace:
$ kubectl get service --namespace=kube-system
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns 10.0.0.10 <none> 53/UDP,53/TCP 12d
kubernetes-dashboard 10.0.0.36 nodes 80/TCP 12d
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (5 by maintainers)
Commits related to this issue
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to kubernetes/kubernetes by deleted user 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to kubernetes/kube-aggregator by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to kubernetes/sample-apiserver by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to kubernetes/apiextensions-apiserver by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to kubernetes/apiextensions-apiserver by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to sttts/kube-aggregator by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to sttts/sample-apiserver by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to sttts/apiextensions-apiserver by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to sttts/apiextensions-apiserver by k8s-publishing-bot 6 years ago
- Merge pull request #60135 from superbrothers/fix-completion-error-in-bash-3 Automatic merge from submit-queue (batch tested with PRs 60346, 60135, 60289, 59643, 52640). If you want to cherry-pick thi... — committed to openshift/kubernetes-sample-apiserver by k8s-publishing-bot 6 years ago
The above was with 1.2.x kubectl and completions. I upgraded to 1.3.0 and now it errors out on completions with namespace:
@superbrothers Thanks, I can confirm 1.9.0-alpha.2 of kubectl works fine 👍
I might be wrong, but this issue is still valid when using the shorthand flag -n, such as:
kubectl -n <namespace> get <tab tab>
returns pod suggestions from the default namespace
I can confirm that the issue I reported is fixed in the release version 1.8.1. Thanks a lot!
https://github.com/kubernetes/kubernetes/issues/29322#issuecomment-234102427
@yissachar The above error does not occurs on v1.8.
https://github.com/kubernetes/kubernetes/issues/29322#issuecomment-236282692
https://github.com/kubernetes/kubernetes/issues/29322#issuecomment-283444545
@philk @n-rook The above error has been fixed by https://github.com/kubernetes/kubernetes/pull/48553.
https://github.com/kubernetes/kubernetes/issues/29322#issuecomment-249818999
@davidreuss The above error will be fixed by https://github.com/kubernetes/kubernetes/pull/54406.
https://github.com/kubernetes/kubernetes/issues/29322#issuecomment-288563190
@lqueryvg I could not reproduce the above error on v1.8. Could you give me more information?
FYI, I have my own rather horrible workaround which is as follows:
Instead of:
source <(kubectl completion zsh)
I run:source <(kubectl completion zsh | sed -e '/flaghash.*true/s/# pad/2>\/dev\/null # pad/')
Basically, this line:
flaghash[${flagname}]="true" # pad "true" for bool flag
Becomes:flaghash[${flagname}]="true" 2>/dev/null # pad "true" for bool flag
The actual completion behaviour still seems to work correctly, so I’m just throwing away the annoying message.
Needs a proper solution though.