Skip to content

Commit d331eaa

Browse files
committed
pkg/cli: use --plugins to determine which plugin.Base's kubebuilder
should run for a subcommand. This option is global. Refactoring of getBaseFlags -> parseBaseFlags allows multiple global flags to be parsed for a cli struct. plugin filtering considers short names, ex. --plugins="go" rather than --plugins="go.kubebuilder.io/v2.0.0". WithDefaultPlugins sets the default plugins a CLi should use in case --plugins or the config 'layout' are not set pkg/model/config: Config support the 'layout' key which indicates the plugin that scaffolded a project, by plugin key pkg/plugin: SplitKey, KeyFor, Key, GetShortName are utility functions for plugin keys * pkg/{cli,plugin}: add plugin name validation * pkg/plugin/{v1,v2}: set layout key in config Please enter the commit message for your changes. Lines starting
1 parent e1d2f11 commit d331eaa

File tree

16 files changed

+342
-147
lines changed

16 files changed

+342
-147
lines changed

cmd/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func main() {
3131
&pluginv1.Plugin{},
3232
&pluginv2.Plugin{},
3333
),
34+
cli.WithDefaultPlugins(
35+
&pluginv1.Plugin{},
36+
&pluginv2.Plugin{},
37+
),
3438
cli.WithExtraCommands(
3539
newEditCmd(),
3640
newUpdateCmd(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ project versions (via `SupportedProjectVersions()`).
6262
Example `PROJECT` file:
6363

6464
```yaml
65-
version: "3-alpha"
65+
version: "2"
6666
layout: go/v1.0.0
6767
domain: testproject.org
6868
repo: github.com/test-inc/testproject

pkg/cli/api.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,9 @@ func (c cli) newAPIContext() plugin.Context {
5555
}
5656

5757
func (c cli) bindCreateAPI(ctx plugin.Context, cmd *cobra.Command) {
58-
versionedPlugins, err := c.getVersionedPlugins()
59-
if err != nil {
60-
cmdErr(cmd, err)
61-
return
62-
}
6358
var getter plugin.CreateAPIPluginGetter
6459
var hasGetter bool
65-
for _, p := range versionedPlugins {
60+
for _, p := range c.resolvedPlugins {
6661
tmpGetter, isGetter := p.(plugin.CreateAPIPluginGetter)
6762
if isGetter {
6863
if hasGetter {

0 commit comments

Comments
 (0)