Commit Graph

15 Commits

Author SHA1 Message Date
Maciej Szulik 307936eb9d Swap KUBECTL_COMMAND_HEADERS to use the proper feature gate mechanism
Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: e3f3da5e795960508089aed08fe7fd9bec0a6db2
2025-05-08 14:09:17 +02:00
Dr. Stefan Schimanski bea8dbbff9 kubectl: fix plugin lookup with positional arguments
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>

Kubernetes-commit: 62d379fa5abd4f109b1f1dfe2112feff03c569b4
2024-03-31 19:44:03 +02:00
Arda Güçlü c2f0957625 KEP-3638: Promote plugin resolution to beta (#120663)
* Promote plugin resolution to beta

* Not use plugin for kubectl create -f command execution

`kubectl create -f` is legitimate command execution and we shouldn't
search plugins if user invokes this.

* Add integration test for plugin resolution for create command

* Reintroduce feature flag to ability to disable it explicitly

Kubernetes-commit: 074a8b00840e85cc95fd83b1825b14ab21ad09c4
2023-10-23 14:41:38 +03:00
Filip Křepinský a71362e506 rename err to lookupErr
Kubernetes-commit: bafae5c0764a222e336de1d7ce2645186bb455dd
2023-05-15 16:41:54 +02:00
Filip Křepinský 3ebdc043ce fix false positive kubectl plugin unit tests
- test.args should be passed instead of the os.Args of the test framework
  to prevent simple invocation of kubectl without args that could
  manifest in false positive test runs
- plugin execution should have a different test path
- tests should invoke functioning kubectl commands instead of the mock
  ones to ensure the correct subcommand is executed without a failure

Kubernetes-commit: 8b9cbe62025da49a31518870f2aea0ce9797d3ce
2023-05-11 20:12:38 +02:00
Chris Bandy facdb16b53 Replace os.Setenv with testing.T.Setenv in tests
T.Setenv ensures that the environment is returned to its prior state
when the test ends. It also panics when called from a parallel test to
prevent racy test interdependencies.

Kubernetes-commit: 2181eea48435310d1b6e366ea8db2968c4941b93
2023-04-15 10:09:47 -05:00
Arda Güçlü 3f05cfcd78 Migrate genericclioptions.IOStreams usage to genericiooptions
Kubernetes-commit: 00c30941260a27e6929aef84c7fdbc8f1508518c
2023-04-05 14:07:46 +03:00
Arda Güçlü d3f76f431e Enable plugin resolution as subcommand for selected builtin commands (#116293)
* Enable plugin resolution as subcommand for selected builtin commands

This PR adds external plugin resolution as subcommand for selected builtin
commands if subcommand does not exist as builtin.

In it's alpha stage, this will only be enabled for create command and
this feature is hidden behind `KUBECTL_ENABLE_CMD_SHADOW` environment variable.

* Rename parameter to exactMatch to better reflect

Kubernetes-commit: a901bb630b5a353898c1b35df582a7faeef160a0
2023-03-09 16:16:01 +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
Sam Snarr e25bbbc6e1 fixed test to fail when you change the `expectPluginArgs` so that it is different than `args`
Kubernetes-commit: 45fc1f0d93b996b0bc84cdcaec47ff60b8c21b4d
2022-10-27 22:18:42 -04:00
Maciej Szulik 19d74f894c Switch from arguments to an input structure for kubectl command
Kubernetes-commit: baab99d04cd4c4314525e19c14ec85a072161cb1
2021-11-04 16:29:08 +01:00
Marc Khouzam e6118325f3 Ignore flags that could precede the Cobra command
See https://github.com/kubernetes/kubectl/issues/1119

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

Kubernetes-commit: d41c2685b67317fea1d1a3843d8f5870bc724b3b
2021-09-20 18:20:49 -04:00
Marc Khouzam 10504c18ad Do not try to load plugins for cobra commands
Cobra adds the commands 'help', '__complete' and '__completeNoDesc'
inside rootCmd.Execute(), however, when kubectl decides if it should
lookup plugins, rootCmd.Execute() had not been called yet.  Therefore,
the call to cmd.Find(cmdPathPieces) done by kubectl does not find the
commands added by Cobra.  To fix this we must check for them explicitly.

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

Kubernetes-commit: e703b3d25377e763b117805b3d88fe7236f3ff76
2021-09-19 14:34:10 -04:00
Sean Sullivan 42a8170920 kubectl command headers as default in beta
Kubernetes-commit: 4add8ed910654087683444ac7f8e441e8d32baa3
2021-06-26 20:53:49 -07:00
Maciej Szulik d64f53f6eb Move the remaining kubectl bits to k8s.io/kubectl
Kubernetes-commit: 9b8247e5ddb15f3fb9ffe59871172d9a3268af55
2020-11-03 22:11:39 +01:00