Skip to content

Commit

Permalink
🐛 fix: ensure --make=false option is available for webhook creation f…
Browse files Browse the repository at this point in the history
…or consistency (#4275)

fix: ensure --make=false option is available for webhook creation for consistency

Standardize resource generation options by adding the `--make=false` flag to `kubebuilder create webhook`, aligning it with the existing API creation process. This option is essential in scenarios such as project scaffolding, where running `make` commands immediately is deferred to allow modifications to generated files before execution.
  • Loading branch information
camilamacedo86 authored Oct 31, 2024
1 parent dd6b632 commit d500f48
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/plugins/golang/v4/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type createWebhookSubcommand struct {
// Deprecated - TODO: remove it for go/v5
// isLegacyPath indicates that the resource should be created in the legacy path under the api
isLegacyPath bool

// runMake indicates whether to run make or not after scaffolding APIs
runMake bool
}

func (p *createWebhookSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
Expand All @@ -69,6 +72,8 @@ validating and/or conversion webhooks.
func (p *createWebhookSubcommand) BindFlags(fs *pflag.FlagSet) {
p.options = &goPlugin.Options{}

fs.BoolVar(&p.runMake, "make", true, "if true, run `make generate` after generating files")

fs.StringVar(&p.options.Plural, "plural", "", "resource irregular plural form")

fs.BoolVar(&p.options.DoDefaulting, "defaulting", false,
Expand Down Expand Up @@ -145,10 +150,13 @@ func (p *createWebhookSubcommand) PostScaffold() error {
return err
}

err = pluginutil.RunCmd("Running make", "make", "generate")
if err != nil {
return err
if p.runMake {
err = pluginutil.RunCmd("Running make", "make", "generate")
if err != nil {
return err
}
}

fmt.Print("Next: implement your new Webhook and generate the manifests with:\n$ make manifests\n")

return nil
Expand Down

0 comments on commit d500f48

Please sign in to comment.