Commit Graph

4 Commits

Author SHA1 Message Date
Matthias Riegler 90963a2f06 feat: make user-defined plugins discoverable with e.g. kubectl help (#116752)
* feat: make user-defined plugins discoverable with e.g. kubectl help

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: make help text localizable & rename it

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* chore: address CRs, cleanup

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: plugin execution

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

---------

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

Kubernetes-commit: d7b7a85fbc0b3831cbc6a750a47dfdcdf777d519
2023-09-06 18:12:52 +02:00
Arda Güçlü 3f05cfcd78 Migrate genericclioptions.IOStreams usage to genericiooptions
Kubernetes-commit: 00c30941260a27e6929aef84c7fdbc8f1508518c
2023-04-05 14:07:46 +03:00
inosato 8272d71ba6 Remove ioutil from kubectl
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 774ab1349bfd553c97a99b992e9f38659f541c84
2022-07-30 22:31:16 +09:00
Marc Khouzam d2df859d92 Add support for shell completion for plugins
When doing completion for arguments or flags for a plugin, kubectl will
call "kubectl_complete-<plugin>" to obtain the list of completions.
For example, for "krew" plugin, when the user triggers completion using:

$ kubectl krew <tab><tab>

kubectl will look for an executable file called "kubectl_complete-krew".
This file should print the list of valid completions for the plugin to
stdout.  Using cobra.ShellCompDirective as the last line of the output
is supported as is done by Cobra.

We also clear global flags when doing plugin completion because plugins
don't necessarily accept the global kubectl flags.  If some plugins do,
they will need to include such flags in their kubectl_complete-<plugin>
output.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: befc8da7efa5d961d9ade4eadc706292c7ca5a64
2021-09-15 21:44:07 -04:00