kubel icon indicating copy to clipboard operation
kubel copied to clipboard

Error: flags cannot be placed before plugin name: --context when context name has spaces in it

Open mogorman opened this issue 2 years ago • 4 comments

i can work around by wrapping the context name in single quotes but would be nice if it just did it

mogorman avatar Mar 03 '22 03:03 mogorman

Just to be clear, you are seeing the error message "flags cannot be placed before plugin name: --context" whenever you work in a context that has spaces in its name? like kubectl --context "my context" get pods would be an equivalent command?

abrochard avatar Mar 03 '22 12:03 abrochard

so my contexts are named aws eks staging env

when it tries to run it it runs it as kubectl --contex aws eks staging env --context which fails it needs to be quoted. given emacs could detect spaces seems like we could wrap it so that the kubectl commands are excecuted correctly.

I worked around it by just renaming my context to single word names, but these configs arent managed by me so will have to do this each time they are updated.

mogorman avatar Mar 03 '22 18:03 mogorman

I see. Thanks for bringing that up. This would require a bit of work and some testing, especially since one would have to have a context with spaces to verify. I imagine the bulk of the work would have to be around the kubel-set-context function.

In the meantime, yes renaming context to have no spaces is a good workaround.

Also I understand you do not manage the cluster, but I have to admit that having spaces in context is extremely odd and not recommended in general.

abrochard avatar Mar 04 '22 02:03 abrochard

ya no disagreement there. spaces_are_bad_in_general.

mogorman avatar Mar 04 '22 21:03 mogorman