Commit Graph

19 Commits

Author SHA1 Message Date
Kazuki Suda 9c405e27d0 Add completion support for kubectl plugins
This commit allows us to get shell completion for kubectl plugins.

For example, with the use of a plugin named 'kubectl-krew', completing
   kubectl k<tab>
will include 'krew' in the list of possible completions.

Because the shell completion scripts are generated by Cobra, this commit
took the approach of registering every plugin as a Cobra command.  This
makes Cobra aware of each plugin command when generating completions.

For efficiency, searching for plugins and registering them as Cobra
commands is only done when needed, which is when calling the
'kubectl completion' command in the case of bash, as it includes all
commands and subcommands directly in the bash generated script.

For the other shells, this will need to be done for the
'kubectl __complete' command, in a follow-up command.

Co-authored-by: Marc Khouzam <marc.khouzam@montreal.ca>
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>

Kubernetes-commit: 3db3ff53cdf4b106365c5de9194153fc371868a7
2019-04-14 14:40:53 +09:00
Daniel Helfand 76bcd89a57 include powershell in short description for kubectl completion
Kubernetes-commit: 67e692d521a5904aaaea446fd1642d2696cab61f
2022-05-03 20:56:41 -05:00
Brian Pursley 0c3ff4c860 Add unit tests for completion command
Kubernetes-commit: a8ec462e6fdbceb0a0e96446511b8b7e5e4b7781
2022-05-14 11:12:00 -04:00
brianpursley 24505ed13a Upgrade Cobra from 1.2.1 to 1.3.0 to fix a bug where bash completions don't work when the kubectl command uses the --context flag to specify a context that contains a colon
Kubernetes-commit: 64fac6cf49839ba058345dc471f038e5008a05f1
2022-01-12 10:37:13 -05:00
Paul Barfuss 0208a3ee09 Replace hardcoded kubectl with kubectl.Name()
Kubernetes-commit: 77be26c3b83dd28be450c8790ecee823750f9a8c
2021-12-10 15:58:52 -05:00
Paul Barfuss 9b4102b899 kubectl: fix hard-coded value in zsh completion
Kubernetes-commit: 339c361ca0156cbf2be5aa64f52a0afd332f5708
2021-12-07 15:13:39 -05:00
Zovin Khanmohammed 723266d145 Adds the PowerShell completion generation (#103758)
* Adds the powershell completion generation

* Fixes formatting based on verification script

* Changes generation to include descriptions

* Adjusts formatting and Adds startup information

* Fix build

Kubernetes-commit: dec8528abaa58a4c7fc190df2cad8848799f9891
2021-08-25 22:29:23 -05:00
Wei Lun cdae2c3d88 fix indentation
Kubernetes-commit: 8a1987f0da1d6d881272f9609cadc03fa32c6f11
2021-08-10 16:31:32 +08:00
Wei Lun cb657f63a2 add kubectl fish shell completion
Kubernetes-commit: 3f5176c26512fdb9154a0bd1d34ee61196874251
2020-07-11 22:07:05 +08:00
Andrea Hoffer 09ed00ef49 Minor adjustments to descriptions and example text
Kubernetes-commit: 6b736f348483bb6b20d4633319305960f4d9e4c1
2021-07-06 15:05:26 -04:00
Marc Khouzam 4338c5bc89 Use native zsh completion
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: 77bb053102cbe1581857dd35e9c095888d2c85d3
2021-06-05 22:09:03 -04:00
卢振兴10069964 031e3ab456 code cleanup: fix broken link in kubectl completion
Kubernetes-commit: 84df3a213fcb6a91f8b72e66dc610ce399807d10
2021-04-19 14:15:48 +08:00
changshuchao 7d1600ce5a code cleanup for kubectl apply_edit_last_applied.go,wait.go,completion.go,cp.go
Signed-off-by: changshuchao <chang.shuchao1@zte.com.cn>

Kubernetes-commit: e229ca33cff782e0bf602f43312b9a168aa58c4c
2021-03-07 05:04:30 +08:00
xiongzhongliang 269a0a3ee5 fix typo of kubectl completion -h
Kubernetes-commit: fe094b20d2d66a28d4cfb78fcb493d213136cded
2020-12-22 16:49:39 +08:00
renzheng.wang 26aa5c6585 make kubectl/kubeadm completion script support busybox
Kubernetes-commit: ff888f3a43abcb48b773e108baa38858220d88e3
2020-04-08 23:03:53 +08:00
tipok b096826165 fix BusyBox sed
BusyBox sed works the same way as GNU sed

Kubernetes-commit: 6885919986250c33af63933d95b30d1896a8dd07
2020-02-28 11:06:30 +01:00
knight42 4e70f2b1a7 fix(kubectl): remove trailing space when completing file path
Kubernetes-commit: 2fefd9eea4db910eae2b3b86f4834d0892b659dc
2020-03-25 22:54:33 +08:00
Brian Pursley 6464f40812 Removed unnecessary _complete call which was silently failing and causing zsh completion to return a nonzero exit code
Removed unnecessary _complete and _expand aliases for zsh completion

Kubernetes-commit: 04741b150effc1c963c1d1b6b2a8d9ce2019d375
2020-02-21 09:11:44 -05:00
Sean Sullivan c6063dd846 Move pkg/kubectl/cmd/{command} to staging
Kubernetes-commit: 0e0ea523392f1121f61f99ac30a9bc2043eaed90
2019-08-01 11:01:40 -07:00