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
Copy file name to clipboardExpand all lines: docs/book/src/plugins/extending/external-plugins.md
+30-8Lines changed: 30 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,19 @@ standard I/O. Any language can be used to create the plugin, as long
26
26
as it follows the [PluginRequest][code-plugin-external] and [PluginResponse][code-plugin-external]
27
27
structures.
28
28
29
-
### PluginRequest
30
-
31
29
`PluginRequest` contains the data collected from the CLI and any previously executed plugins. Kubebuilder sends this data as a JSON object to the external plugin via `stdin`.
32
30
31
+
**Fields:**
32
+
-`apiVersion`: Version of the PluginRequest schema.
33
+
-`args`: Command-line arguments passed to the plugin.
34
+
-`command`: The subcommand being executed (e.g., `init`, `create api`, `create webhook`, `edit`).
35
+
-`universe`: Map of file paths to contents, updated across the plugin chain.
36
+
-`pluginChain` (optional): Array of plugin keys in the order they were executed. External plugins can inspect this to tailor behavior based on other plugins that ran (for example, `go.kubebuilder.io/v4` or `kustomize.common.kubebuilder.io/v2`).
37
+
-`config` (optional): Serialized PROJECT file configuration for the current project. Use it to inspect metadata, existing resources, or plugin-specific settings. Kubebuilder omits this field before the PROJECT file exists—typically during the first `init`—so plugins should check for its presence.
38
+
39
+
40
+
**Note:** Whenever Kubebuilder has a PROJECT file available (for example during `create api`, `create webhook`, `edit`, or a subsequent `init` run), `PluginRequest` includes the `config` field. During the very first `init` run the field is omitted because the PROJECT file does not exist yet.
41
+
33
42
**Example `PluginRequest` (triggered by `kubebuilder init --plugins go/v4,sampleexternalplugin/v1 --domain my.domain`):**
34
43
35
44
```json
@@ -42,12 +51,25 @@ structures.
42
51
}
43
52
```
44
53
45
-
**Fields:**
46
-
-`apiVersion`: Version of the PluginRequest schema.
47
-
-`args`: Command-line arguments passed to the plugin.
48
-
-`command`: The subcommand being executed (e.g., `init`, `create api`, `create webhook`, `edit`).
49
-
-`universe`: Map of file paths to contents, updated across the plugin chain.
50
-
-`pluginChain` (optional): Array of plugin keys in the chain. This allows external plugins to determine which other plugins are being used. For example, a plugin can check if `go.kubebuilder.io/v4` or `go.kubebuilder.io/v3` is in the chain to adjust its scaffolding accordingly.
54
+
**Example `PluginRequest` for `create api` (includes `config`):**
0 commit comments