Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No tab completion available for kubectl set command #1585

Closed
paololazzari opened this issue Apr 11, 2024 · 3 comments · Fixed by kubernetes/kubernetes#124592
Closed

No tab completion available for kubectl set command #1585

paololazzari opened this issue Apr 11, 2024 · 3 comments · Fixed by kubernetes/kubernetes#124592
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@paololazzari
Copy link

$ source <(kubectl completion bash)
$ kubectl set image deploy/<tab>
$ kubectl set env deploy/<tab>

hitting tab does nothing

@paololazzari paololazzari added the kind/bug Categorizes issue or PR as related to a bug. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 11, 2024
@ah8ad3
Copy link
Member

ah8ad3 commented Apr 13, 2024

I don't know much about completion, tried to find out about problem after some debug here is my output:
After running kubectl set image <TAB>

========= starting completion logic ==========
CURRENT: 4, words[*]: kubectl set image 
Truncated words[*]: kubectl set image ,
lastParam: , lastChar: 
Adding extra empty parameter
About to call: eval kubectl __complete set image  ""
completion output: :0
last line: :0
directive: 0
completions: 
flagPrefix: 
Calling _describe
_describe did not find completions.
Checking if we should do file completion.
Activating file completion

Activating file completion

And it starts to complete from files.

But when we call
kubectl logs <TAB>

========= starting completion logic ==========
CURRENT: 3, words[*]: kubectl logs 
Truncated words[*]: kubectl logs ,
lastParam: , lastChar: 
Adding extra empty parameter
About to call: eval kubectl __complete logs  ""
completion output: nginx-7854ff8877-hc59j
daemonsets/
deployments/
pods/
jobs/
replicasets/
replicationcontrollers/
services/
statefulsets/
:4
last line: :4
directive: 4
completions: nginx-7854ff8877-hc59j
daemonsets/
deployments/
pods/
jobs/
replicasets/
replicationcontrollers/
services/
statefulsets/
flagPrefix: 
Adding completion: nginx-7854ff8877-hc59j
Adding completion: daemonsets/
Adding completion: deployments/
Adding completion: pods/
Adding completion: jobs/
Adding completion: replicasets/
Adding completion: replicationcontrollers/
Adding completion: services/
Adding completion: statefulsets/
Calling _describe
_describe found some completions

And gets you a list of options.

I think we need to add something like this
https://github.com/kubernetes/kubernetes/blob/cae35dba5a3060711a2a3f958537003bc74a59c0/staging/src/k8s.io/kubectl/pkg/util/completion/completion.go#L101
for set command to support this feature.
Also we have another issue for completion to explain it would be nice to fix that too.

@ah8ad3
Copy link
Member

ah8ad3 commented Apr 22, 2024

I was able to fix this issue with a simple approach of set, which is
kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
I'm trying to fix completion to not catch duplicated containers, and cleaning up the code.

@mpuckett159
Copy link
Contributor

/triage accepted
/assign @ah8ad3

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants