kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

Completion not working for `kubectl config set-context --current <namespace>`

Open jheyduk opened this issue 1 year ago • 7 comments

What happened: When using zsh-Autocompletion the autocompletion defaults to directories for kubectl config set-context --current --namespace

What you expected to happen: The command should autocomplete with namespaces

How to reproduce it (as minimally and precisely as possible):

kubectl config set-context --current --namespace Anything else we need to know?:

Environment:

  • Kubernetes client and server versions (use kubectl version): Client Version: v1.29.2 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.29.2
  • Cloud provider or hardware configuration:
  • OS (e.g: cat /etc/os-release):

jheyduk avatar Feb 21 '24 17:02 jheyduk

I confirm this missing functionality. This is because the kubectl config set-context command redefines its own namespace flag and we didn't add shell completion for it.

Until this is fixed, a workaround (slightly annoying) is to instead use the global --namespace flag by putting it before the set-context command:

$ kubectl config --namespace <TAB>
ns1   ns2    ns3
$ kubectl config --namespace ns2 set-context --current <ENTER>
Context "my-context" modified.

# This also works
$ kubectl config --namespace <TAB> set-context --current 
ns1   ns2    ns3

marckhouzam avatar Feb 22 '24 13:02 marckhouzam

/assign

sreeram-venkitesh avatar Feb 28 '24 17:02 sreeram-venkitesh

/triage accepted

mpuckett159 avatar Feb 29 '24 00:02 mpuckett159

/retitle Completion not working for kubectl config set-context --current <namespace>

sftim avatar Apr 23 '24 20:04 sftim

@sreeram-venkitesh would it bother you if I work on this?

TessaIO avatar May 18 '24 19:05 TessaIO

@TessaIO please feel free to take this up!

sreeram-venkitesh avatar May 20 '24 01:05 sreeram-venkitesh

/assign

TessaIO avatar May 20 '24 12:05 TessaIO