kubectl
kubectl copied to clipboard
Fish completion is broken for option flags if/when leading options contain "special" shell characters.
What happened:
Type kubectl
command and invoke [TAB] completion after the "-" prefix .
kubectl get pod -l 'app in(test)' -[TAB]
What you expected to happen: Expected to see completion options like the following:
kubectl get pod -l 'app in(foo)' -
-A --all-namespaces (If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.)
-f --filename (Filename, directory, or URL to files identifying the resource to get from a server.)
-h --help (help for get)
-k --kustomize
...
Instead, kubectl fish completion reports an error:
kubectl get pod -l 'app in(foo)' -fish: Unknown command: foo
in command substitution
called on line 1 of file /opt/homebrew/share/fish/vendor_completions.d/kubectl.fish
in command substitution
called on line 42 of file /opt/homebrew/share/fish/vendor_completions.d/kubectl.fish
in function '__kubectl_perform_completion'
called on line 1 of file /opt/homebrew/share/fish/vendor_completions.d/kubectl.fish
in command substitution
called on line 84 of file /opt/homebrew/share/fish/vendor_completions.d/kubectl.fish
in function '__kubectl_perform_completion_once'
called on line 106 of file /opt/homebrew/share/fish/vendor_completions.d/kubectl.fish
in function '__kubectl_requires_order_preservation'
in command substitution
/opt/homebrew/share/fish/vendor_completions.d/kubectl.fish (line 1): Unknown command
KUBECTL_ACTIVE_HELP=0 kubectl __complete get pod -l app in(foo) -
^~~~^
...
How to reproduce it (as minimally and precisely as possible):
kubectl get pod -l 'app in (foo)' -[TAB]
Anything else we need to know?: This issue is due to the BUG in https://github.com/spf13/cobra with pending fix in PR: https://github.com/spf13/cobra/pull/2095
Environment:
- Kubernetes client and server versions (use
kubectl version
):Client Version: v1.29.2
- Cloud provider or hardware configuration: N/A
- OS (e.g:
cat /etc/os-release
): Any/All
This issue is currently awaiting triage.
SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted
label.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
~Parenthesis ( )
are not valid characters for labels. Were you able to label a pod that way?~
~https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set~
Edit: TIL we have filter querying builtin https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#list-and-watch-filtering
/triage accepted
Folks can i pick this up
Hi @mohitsharma-in if you think you can work to solve this issue you can self assign with /assign
.