Skip to content

Commit

Permalink
Merge pull request #1846 from camilamacedo86/add-make-webhooks
Browse files Browse the repository at this point in the history
✨ add make run option for webhooks (go/v3-alpha)
  • Loading branch information
k8s-ci-robot committed Nov 23, 2020
2 parents 2c3ae8f + 62b58b1 commit eec23b1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/plugins/golang/v3/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"sigs.k8s.io/kubebuilder/v2/pkg/plugin"
"sigs.k8s.io/kubebuilder/v2/pkg/plugins/golang/v3/scaffolds"
"sigs.k8s.io/kubebuilder/v2/pkg/plugins/internal/cmdutil"
"sigs.k8s.io/kubebuilder/v2/pkg/plugins/internal/util"
)

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

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

var (
Expand Down Expand Up @@ -74,6 +78,8 @@ func (p *createWebhookSubcommand) BindFlags(fs *pflag.FlagSet) {
fs.StringVar(&p.resource.WebhookVersion, "webhook-version", defaultWebhookVersion,
"version of {Mutating,Validating}WebhookConfigurations to scaffold. Options: [v1, v1beta1]")

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

fs.BoolVar(&p.defaulting, "defaulting", false,
"if set, scaffold the defaulting webhook")
fs.BoolVar(&p.validation, "programmatic-validation", false,
Expand Down Expand Up @@ -127,5 +133,8 @@ func (p *createWebhookSubcommand) GetScaffolder() (cmdutil.Scaffolder, error) {
}

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

0 comments on commit eec23b1

Please sign in to comment.