You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`kubectl` provides a command `kubectl plugin list` that searches your PATH for valid plugin executables.
68
-
Executing this command causes a traversal of all files in your PATH. Any files that are executable, and begin with `kubectl-` will show up *in the order in which they are present in your PATH* in this command's output.
67
+
`kubectl` provides a command `kubectl plugin list` that searches your `PATH` for valid plugin executables.
68
+
Executing this command causes a traversal of all files in your `PATH`. Any files that are executable, and begin with `kubectl-` will show up *in the order in which they are present in your `PATH`* in this command's output.
69
69
A warning will be included for any files beginning with `kubectl-` that are *not* executable.
70
70
A warning will also be included for any valid plugin files that overlap each other's name.
71
71
@@ -75,8 +75,9 @@ plugins from a community-curated
Additionally, the first argument that is passed to a plugin will always be the full path to the location where it was invoked (`$0` would equal `/usr/local/bin/kubectl-foo` in our example above).
222
+
Additionally, the first argument that is passed to a plugin will always be the full path to the location where it was invoked (`$0` would equal `/usr/local/bin/kubectl-foo` in the example above).
Here are some additional cases where users invoke your plugin while providing additional flags and arguments. This builds upon the `kubectl-foo-bar-baz` plugin from the scenario above.
264
-
-->
265
263
这里是一些用户调用你的插件的时候提供额外标志和参数的场景。
266
264
这些场景时基于上述案例中的 `kubectl-foo-bar-baz` 插件的。
267
265
268
266
<!--
269
-
If you run `kubectl foo bar baz arg1 -flag=value arg2`, kubectl's plugin mechanism will first try to find the plugin with the longest possible name, which in this case
267
+
If you run `kubectl foo bar baz arg1 --flag=value arg2`, kubectl's plugin mechanism will first try to find the plugin with the longest possible name, which in this case
270
268
would be `kubectl-foo-bar-baz-arg1`. Upon not finding that plugin, kubectl then treats the last dash-separated value as an argument (`arg1` in this case), and attempts to find the next longest possible name, `kubectl-foo-bar-baz`.
271
269
Upon having found a plugin with this name, kubectl then invokes that plugin, passing all args and flags after the plugin's name as arguments to the plugin process.
272
270
-->
@@ -309,9 +307,9 @@ My first command-line argument was arg1
309
307
```
310
308
311
309
<!--
312
-
As you can see, our plugin was found based on the `kubectl` command specified by a user, and all extra arguments and flags were passed as-is to the plugin executable once it was found.
310
+
As you can see, your plugin was found based on the `kubectl` command specified by a user, and all extra arguments and flags were passed as-is to the plugin executable once it was found.
313
311
-->
314
-
正如你所看到的,我们的插件是基于用户指定的`kubectl` 命令找到的,
312
+
正如你所看到的,你的插件是基于用户指定的`kubectl` 命令找到的,
315
313
所有额外的参数和标记都是按原样传递给插件可执行文件的。
316
314
317
315
<!--
@@ -344,10 +342,10 @@ I am a plugin with a dash in my name
344
342
```
345
343
346
344
<!--
347
-
Note that the introduction of underscores to a plugin filename does not prevent us from having commands such as `kubectl foo_bar`.
345
+
Note that the introduction of underscores to a plugin filename does not prevent you from having commands such as `kubectl foo_bar`.
348
346
The command from the above example, can be invoked using either a dash (`-`) or an underscore (`_`):
349
347
-->
350
-
请注意,在插件文件名中引入下划线并不会阻止我们使用`kubectl foo_bar` 之类的命令。
348
+
请注意,在插件文件名中引入下划线并不会阻止你使用`kubectl foo_bar` 之类的命令。
351
349
可以使用破折号(`-`)或下划线(`_`)调用上面示例中的命令:
352
350
353
351
```shell
@@ -371,8 +369,8 @@ I am a plugin with a dash in my name
371
369
<!--
372
370
#### Name conflicts and overshadowing
373
371
374
-
It is possible to have multiple plugins with the same filename in different locations throughout your PATH.
375
-
For example, given a PATH with the following value: `PATH=/usr/local/bin/plugins:/usr/local/bin/moreplugins`, a copy of plugin `kubectl-foo` could exist in `/usr/local/bin/plugins` and `/usr/local/bin/moreplugins`,
372
+
It is possible to have multiple plugins with the same filename in different locations throughout your `PATH`.
373
+
For example, given a `PATH` with the following value: `PATH=/usr/local/bin/plugins:/usr/local/bin/moreplugins`, a copy of plugin `kubectl-foo` could exist in `/usr/local/bin/plugins` and `/usr/local/bin/moreplugins`,
376
374
such that the output of the `kubectl plugin list` command is:
377
375
-->
378
376
#### 命名冲突和弊端
@@ -397,54 +395,58 @@ error: one plugin warning was found
397
395
```
398
396
399
397
<!--
400
-
In the above scenario, the warning under `/usr/local/bin/moreplugins/kubectl-foo` tells us that this plugin will never be executed. Instead, the executable that appears first in our PATH, `/usr/local/bin/plugins/kubectl-foo`, will always be found and executed first by the `kubectl` plugin mechanism.
398
+
In the above scenario, the warning under `/usr/local/bin/moreplugins/kubectl-foo` tells you that this plugin will never be executed. Instead, the executable that appears first in your `PATH`, `/usr/local/bin/plugins/kubectl-foo`, will always be found and executed first by the `kubectl` plugin mechanism.
A way to resolve this issue is to ensure that the location of the plugin that you wish to use with `kubectl` always comes first in your PATH. For example, if we wanted to always use `/usr/local/bin/moreplugins/kubectl-foo` anytime that the `kubectl` command `kubectl foo` was invoked, we would simply change the value of our PATH to be `PATH=/usr/local/bin/moreplugins:/usr/local/bin/plugins`.
405
+
A way to resolve this issue is to ensure that the location of the plugin that you wish to use with `kubectl` always comes first in your `PATH`. For example, if you want to always use `/usr/local/bin/moreplugins/kubectl-foo` anytime that the `kubectl` command `kubectl foo` was invoked, change the value of your `PATH` to be `/usr/local/bin/moreplugins:/usr/local/bin/plugins`.
#### Invocation of the longest executable filename
415
413
416
-
There is another kind of overshadowing that can occur with plugin filenames. Given two plugins present in a user's PATH `kubectl-foo-bar` and `kubectl-foo-bar-baz`, the `kubectl` plugin mechanism will always choose the longest possible plugin name for a given user command. Some examples below, clarify this further:
414
+
There is another kind of overshadowing that can occur with plugin filenames. Given two plugins present in a user's `PATH`: `kubectl-foo-bar` and `kubectl-foo-bar-baz`, the `kubectl` plugin mechanism will always choose the longest possible plugin name for a given user command. Some examples below, clarify this further:
0 commit comments