@@ -37,17 +37,18 @@ import (
3737
3838// WebhookBuilder builds a Webhook.
3939type WebhookBuilder struct {
40- apiType runtime.Object
41- customDefaulter admission.CustomDefaulter
42- customDefaulterOpts []admission.DefaulterOption
43- customValidator admission.CustomValidator
44- customPath string
45- gvk schema.GroupVersionKind
46- mgr manager.Manager
47- config * rest.Config
48- recoverPanic * bool
49- logConstructor func (base logr.Logger , req * admission.Request ) logr.Logger
50- err error
40+ apiType runtime.Object
41+ customDefaulter admission.CustomDefaulter
42+ customDefaulterOpts []admission.DefaulterOption
43+ customValidator admission.CustomValidator
44+ validatingCustomPath string
45+ defaultingCustomPath string
46+ gvk schema.GroupVersionKind
47+ mgr manager.Manager
48+ config * rest.Config
49+ recoverPanic * bool
50+ logConstructor func (base logr.Logger , req * admission.Request ) logr.Logger
51+ err error
5152}
5253
5354// WebhookManagedBy returns a new webhook builder.
@@ -95,9 +96,15 @@ func (blder *WebhookBuilder) RecoverPanic(recoverPanic bool) *WebhookBuilder {
9596 return blder
9697}
9798
98- // WithCustomPath overrides the webhook's default path by the customPath
99- func (blder * WebhookBuilder ) WithCustomPath (customPath string ) * WebhookBuilder {
100- blder .customPath = customPath
99+ // WithValidatingCustomPath overrides the webhook's default validating path by the customPath
100+ func (blder * WebhookBuilder ) WithValidatingCustomPath (customPath string ) * WebhookBuilder {
101+ blder .validatingCustomPath = customPath
102+ return blder
103+ }
104+
105+ // WithDefaultingCustomPath overrides the webhook's default defaulting path by the customPath
106+ func (blder * WebhookBuilder ) WithDefaultingCustomPath (customPath string ) * WebhookBuilder {
107+ blder .defaultingCustomPath = customPath
101108 return blder
102109}
103110
@@ -174,8 +181,8 @@ func (blder *WebhookBuilder) registerDefaultingWebhook() error {
174181 if mwh != nil {
175182 mwh .LogConstructor = blder .logConstructor
176183 path := generateMutatePath (blder .gvk )
177- if blder .customPath != "" {
178- generatedCustomPath , err := generateCustomPath (blder .customPath )
184+ if blder .defaultingCustomPath != "" {
185+ generatedCustomPath , err := generateCustomPath (blder .defaultingCustomPath )
179186 if err != nil {
180187 return err
181188 }
@@ -212,8 +219,8 @@ func (blder *WebhookBuilder) registerValidatingWebhook() error {
212219 if vwh != nil {
213220 vwh .LogConstructor = blder .logConstructor
214221 path := generateValidatePath (blder .gvk )
215- if blder .customPath != "" {
216- generatedCustomPath , err := generateCustomPath (blder .customPath )
222+ if blder .validatingCustomPath != "" {
223+ generatedCustomPath , err := generateCustomPath (blder .validatingCustomPath )
217224 if err != nil {
218225 return err
219226 }
0 commit comments