Skip to content

Commit c284873

Browse files
committed
clarify sentence on project type; add Name() to Plugin interface
1 parent 53afd47 commit c284873

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

designs/extensible-cli-and-scaffolding-plugins.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Extensible CLI and Scaffolding Plugins
22

3-
## Overview
4-
I would like for Kubebuilder to become more extensible, such that it could be imported and used as a library in other projects. Specifically, I'm looking for a way to use Kubebuilder's existing CLI and scaffolding for Go projects, but to also be able to augment Kubebuilder's project versions with other custom project versions so that I can support the Kubebuilder workflow with non-Go operators (e.g. operator-sdk's Ansible and Helm-based operators).
3+
## Overview
4+
I would like for Kubebuilder to become more extensible, such that it could be imported and used as a library in other projects. Specifically, I'm looking for a way to use Kubebuilder's existing CLI and scaffolding for Go projects, but to also be able to augment the Kubebuilder project structure with other custom project types so that I can support the Kubebuilder workflow with non-Go operators (e.g. operator-sdk's Ansible and Helm-based operators).
55

66
The idea is for Kubebuilder to define one or more plugin interfaces that can be used to drive what the `init`, `create api` and `create webhooks` subcommands do and to add a new `cli` package that other projects can use to integrate out-of-tree plugins with the Kubebuilder CLI in their own projects.
77

@@ -21,9 +21,12 @@ Each plugin would minimally be required to implement the `Plugin` interface.
2121

2222
```go
2323
type Plugin interface {
24-
// Version is the project version that this plugin implements.
25-
// For example, Kubebuilder's Go v2 plugin implementation would return "2"
26-
Version() string
24+
// Version returns the project version that this plugin implements.
25+
// For example, Kubebuilder's Go v2 plugin implementation would return 2.
26+
Version() uint
27+
// Name returns a name defining the plugin type.
28+
// For example, Kubebuilder's plugins would return "go".
29+
Name() string
2730
}
2831
```
2932

@@ -33,7 +36,7 @@ Next, a plugin could optionally implement further interfaces to declare its supp
3336
* `CreateAPIPlugin` - to create APIs (and possibly controllers) for existing projects
3437
* `CreateWebhookPlugin` - to create webhooks for existing projects
3538

36-
Each of these interfaces would follow the same pattern (see the InitPlugin interface example below).
39+
Each of these interfaces would follow the same pattern (see the `InitPlugin` interface example below).
3740

3841
```go
3942
type InitPlugin interface {
@@ -66,7 +69,7 @@ To generically support deprecated project versions, we could also add a `Depreca
6669
// that the plugin is deprecated. The CLI uses this to print deprecation
6770
// warnings when the plugin is in use.
6871
type Deprecated interface {
69-
// DeprecationWarning returns a deprecation message that callers
72+
// DeprecationWarning returns a deprecation message that callers
7073
// can use to warn users of deprecations
7174
DeprecationWarning() string
7275
}
@@ -122,7 +125,7 @@ func main() {
122125
## Comments & Questions
123126

124127
### Cobra Commands
125-
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.
128+
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.
126129

127130
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.
128131

0 commit comments

Comments
 (0)