Skip to content

Commit d500f48

Browse files
🐛 fix: ensure --make=false option is available for webhook creation for 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.
1 parent dd6b632 commit d500f48

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pkg/plugins/golang/v4/webhook.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ type createWebhookSubcommand struct {
4848
// Deprecated - TODO: remove it for go/v5
4949
// isLegacyPath indicates that the resource should be created in the legacy path under the api
5050
isLegacyPath bool
51+
52+
// runMake indicates whether to run make or not after scaffolding APIs
53+
runMake bool
5154
}
5255

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

75+
fs.BoolVar(&p.runMake, "make", true, "if true, run `make generate` after generating files")
76+
7277
fs.StringVar(&p.options.Plural, "plural", "", "resource irregular plural form")
7378

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

148-
err = pluginutil.RunCmd("Running make", "make", "generate")
149-
if err != nil {
150-
return err
153+
if p.runMake {
154+
err = pluginutil.RunCmd("Running make", "make", "generate")
155+
if err != nil {
156+
return err
157+
}
151158
}
159+
152160
fmt.Print("Next: implement your new Webhook and generate the manifests with:\n$ make manifests\n")
153161

154162
return nil

0 commit comments

Comments
 (0)