Skip to content

Commit 5187a15

Browse files
committed
explain PROJECT file updates and plugin version/name conventions
1 parent b647850 commit 5187a15

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

designs/extensible-cli-and-scaffolding-plugins.md renamed to designs/extensible-cli-and-scaffolding-plugins-phase-1.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,53 @@ Each plugin would minimally be required to implement the `Plugin` interface.
2525

2626
```go
2727
type Plugin interface {
28-
// Version returns the project version that this plugin implements.
29-
// For example, Kubebuilder's Go v2 plugin implementation would return 2.
28+
// Version returns the plugin's semantic version, ex. "v1.2.3".
29+
//
30+
// Note: this version is different from config version.
3031
Version() string
31-
// Name returns a name defining the plugin type.
32-
// For example, Kubebuilder's plugins would return "go".
32+
// Name returns a DNS1123 label string defining the plugin type.
33+
// For example, Kubebuilder's main plugin would return "go".
34+
//
35+
// Plugin names can be fully-qualified, and non-fully-qualified names are
36+
// prepended to ".kubebuilder.io" to prevent conflicts.
3337
Name() string
38+
// SupportedProjectVersions lists all project configuration versions this
39+
// plugin supports, ex. []string{"2", "3"}. The returned slice cannot be empty.
40+
SupportedProjectVersions() []string
3441
}
3542
```
3643

44+
#### Plugin naming
45+
46+
Plugin names (returned by `Name()`) must be DNS1123 labels. The returned name
47+
may be fully qualified (fq), ex. `go.kubebuilder.io`, or not but internally will
48+
always be fq by either appending `.kubebuilder.io` to the name or using an
49+
existing qualifier defined by the plugin. FQ names prevent conflicts between
50+
plugin names; the plugin runner will ask the user to add a name qualifier to
51+
a conflicting plugin.
52+
53+
#### Project file plugin `layout`
54+
55+
The `PROJECT` file will specify what base plugin generated the project under
56+
a `layout` key. `layout` will have the format: `Plugin.Name() + "/" + Plugin.Version()`.
57+
`version` and `layout` have versions with different meanings: `version` is the
58+
project config version, while `layout`'s version is the plugin semantic version.
59+
The value in `version` will determine that in `layout` by a plugin's supported
60+
project versions (via `SupportedProjectVersions()`).
61+
62+
Example `PROJECT` file:
63+
64+
```yaml
65+
version: "3-alpha"
66+
layout: go/v1.0.0
67+
domain: testproject.org
68+
repo: github.com/test-inc/testproject
69+
resources:
70+
- group: crew
71+
kind: Captain
72+
version: v1
73+
```
74+
3775
### Optional
3876
3977
Next, a plugin could optionally implement further interfaces to declare its support for specific Kubebuilder subcommands. For example:
@@ -144,6 +182,8 @@ func main() {
144182

145183
### Cobra Commands
146184

185+
**RESOLUTION:** `cobra` will be used directly in Phase 1 since it is a widely used, feature-rich CLI package. This, however unlikely, may change in future phases.
186+
147187
As discussed earlier as part of [#1148](https://github.com/kubernetes-sigs/kubebuilder/pull/1148), one goal is to eliminate the use of `cobra.Command` in the exported API of Kubebuilder since that is considered an internal implementation detail.
148188

149189
However, at some point, projects that make use of this extensibility will likely want to integrate their own subcommands. In this proposal, `cli.WithExtraCommands()` _DOES_ expose `cobra.Command` to allow callers to pass their own subcommands to the CLI.
@@ -161,6 +201,6 @@ Are there other ideas for how to handle the following requirements?
161201
* Support cohesive help output
162202

163203
### Other
164-
1. Should the `InitPlugin` interface methods be required of all plugins?
165-
2. Any other approaches or ideas?
166-
3. Anything I didn't cover that could use more explanation?
204+
1. ~Should the `InitPlugin` interface methods be required of all plugins?~ No
205+
2. ~Any other approaches or ideas?~
206+
3. ~Anything I didn't cover that could use more explanation?~

0 commit comments

Comments
 (0)