Skip to content

Commit

Permalink
Don't rewrite potentially shared values
Browse files Browse the repository at this point in the history
Make them constant and use a local var.
  • Loading branch information
justinsb committed Nov 12, 2019
1 parent e6a5211 commit 7623c75
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/scaffold/v2/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ func (a *Webhook) GetInput() (input.Input, error) {
a.Path = filepath.Join("api", a.Resource.Version,
fmt.Sprintf("%s_webhook.go", strings.ToLower(a.Resource.Kind)))
}
webhookTemplate := WebhookTemplate
if a.Defaulting {
WebhookTemplate = WebhookTemplate + DefaultingWebhookTemplate
webhookTemplate = webhookTemplate + DefaultingWebhookTemplate
}
if a.Validating {
WebhookTemplate = WebhookTemplate + ValidatingWebhookTemplate
webhookTemplate = webhookTemplate + ValidatingWebhookTemplate
}

a.TemplateBody = WebhookTemplate
a.TemplateBody = webhookTemplate
a.Input.IfExistsAction = input.Error
return a.Input, nil
}
Expand All @@ -85,7 +86,7 @@ func (g *Webhook) Validate() error {
return g.Resource.Validate()
}

var (
const (
WebhookTemplate = `{{ .Boilerplate }}
package {{ .Resource.Version }}
Expand Down

0 comments on commit 7623c75

Please sign in to comment.