@@ -37,17 +37,18 @@ import (
37
37
38
38
// WebhookBuilder builds a Webhook.
39
39
type 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
51
52
}
52
53
53
54
// WebhookManagedBy returns a new webhook builder.
@@ -95,9 +96,15 @@ func (blder *WebhookBuilder) RecoverPanic(recoverPanic bool) *WebhookBuilder {
95
96
return blder
96
97
}
97
98
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
101
108
return blder
102
109
}
103
110
@@ -174,8 +181,8 @@ func (blder *WebhookBuilder) registerDefaultingWebhook() error {
174
181
if mwh != nil {
175
182
mwh .LogConstructor = blder .logConstructor
176
183
path := generateMutatePath (blder .gvk )
177
- if blder .customPath != "" {
178
- generatedCustomPath , err := generateCustomPath (blder .customPath )
184
+ if blder .defaultingCustomPath != "" {
185
+ generatedCustomPath , err := generateCustomPath (blder .defaultingCustomPath )
179
186
if err != nil {
180
187
return err
181
188
}
@@ -212,8 +219,8 @@ func (blder *WebhookBuilder) registerValidatingWebhook() error {
212
219
if vwh != nil {
213
220
vwh .LogConstructor = blder .logConstructor
214
221
path := generateValidatePath (blder .gvk )
215
- if blder .customPath != "" {
216
- generatedCustomPath , err := generateCustomPath (blder .customPath )
222
+ if blder .validatingCustomPath != "" {
223
+ generatedCustomPath , err := generateCustomPath (blder .validatingCustomPath )
217
224
if err != nil {
218
225
return err
219
226
}
0 commit comments