Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Remove make calls from post-scaffold hooks #1983

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/plugins/golang/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ After the scaffold is written, api will run make on the project.
}

func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {
fs.BoolVar(&p.runMake, "make", true, "if true, run make after generating files")
fs.BoolVar(&p.runMake, "make", true, "if true, run `make generate` after generating files")
Adirio marked this conversation as resolved.
Show resolved Hide resolved

if os.Getenv("KUBEBUILDER_ENABLE_PLUGINS") != "" {
fs.StringVar(&p.pattern, "pattern", "",
Expand Down Expand Up @@ -198,8 +198,8 @@ func (p *createAPISubcommand) PostScaffold() error {
return fmt.Errorf("unknown pattern %q", p.pattern)
}

if p.runMake {
return util.RunCmd("Running make", "make")
if p.runMake { // TODO: check if API was scaffolded
return util.RunCmd("Running make", "make", "generate")
Adirio marked this conversation as resolved.
Show resolved Hide resolved
}
return nil
}
5 changes: 0 additions & 5 deletions pkg/plugins/golang/v2/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ func (p *initSubcommand) PostScaffold() error {
return err
}

err = util.RunCmd("Running make", "make")
if err != nil {
return err
}

fmt.Printf("Next: define a resource with:\n$ %s create api\n", p.commandName)
return nil
}
6 changes: 3 additions & 3 deletions pkg/plugins/golang/v3/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ After the scaffold is written, api will run make on the project.
}

func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {
fs.BoolVar(&p.runMake, "make", true, "if true, run make after generating files")
fs.BoolVar(&p.runMake, "make", true, "if true, run `make generate` after generating files")

// TODO: remove this when a better solution for using addons is implemented.
if os.Getenv("KUBEBUILDER_ENABLE_PLUGINS") != "" {
Expand Down Expand Up @@ -232,8 +232,8 @@ func (p *createAPISubcommand) PostScaffold() error {
return fmt.Errorf("unknown pattern %q", p.pattern)
}

if p.runMake {
return util.RunCmd("Running make", "make")
if p.runMake { // TODO: check if API was scaffolded
return util.RunCmd("Running make", "make", "generate")
}
return nil
}
6 changes: 0 additions & 6 deletions pkg/plugins/golang/v3/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ func (p *initSubcommand) PostScaffold() error {
return err
}

// TODO: make this conditional with a '--make' flag, like in 'create api'.
err = util.RunCmd("Running make", "make")
if err != nil {
return err
}

fmt.Printf("Next: define a resource with:\n$ %s create api\n", p.commandName)
return nil
}
Expand Down
8 changes: 0 additions & 8 deletions pkg/plugins/golang/v3/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
goPlugin "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/internal/cmdutil"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/internal/util"
)

// defaultWebhookVersion is the default mutating/validating webhook config API version to scaffold.
Expand All @@ -44,9 +43,6 @@ type createWebhookSubcommand struct {

// force indicates that the resource should be created even if it already exists
force bool

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

var (
Expand Down Expand Up @@ -87,7 +83,6 @@ func (p *createWebhookSubcommand) BindFlags(fs *pflag.FlagSet) {
fs.BoolVar(&p.options.DoConversion, "conversion", false,
"if set, scaffold the conversion webhook")

fs.BoolVar(&p.runMake, "make", true, "if true, run make after generating files")
fs.BoolVar(&p.force, "force", false,
"attempt to create resource even if it already exists")
}
Expand Down Expand Up @@ -139,8 +134,5 @@ func (p *createWebhookSubcommand) GetScaffolder() (cmdutil.Scaffolder, error) {
}

func (p *createWebhookSubcommand) PostScaffold() error {
if p.runMake {
return util.RunCmd("Running make", "make")
}
return nil
}