@@ -37,16 +37,17 @@ import (
37
37
38
38
// WebhookBuilder builds a Webhook.
39
39
type WebhookBuilder struct {
40
- apiType runtime.Object
41
- customDefaulter admission.CustomDefaulter
42
- customValidator admission.CustomValidator
43
- customPath string
44
- gvk schema.GroupVersionKind
45
- mgr manager.Manager
46
- config * rest.Config
47
- recoverPanic * bool
48
- logConstructor func (base logr.Logger , req * admission.Request ) logr.Logger
49
- err error
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
50
51
}
51
52
52
53
// WebhookManagedBy returns a new webhook builder.
@@ -67,9 +68,11 @@ func (blder *WebhookBuilder) For(apiType runtime.Object) *WebhookBuilder {
67
68
return blder
68
69
}
69
70
70
- // WithDefaulter takes an admission.CustomDefaulter interface, a MutatingWebhook will be wired for this type.
71
- func (blder * WebhookBuilder ) WithDefaulter (defaulter admission.CustomDefaulter ) * WebhookBuilder {
71
+ // WithDefaulter takes an admission.CustomDefaulter interface, a MutatingWebhook with the provided opts (admission.DefaulterOption)
72
+ // will be wired for this type.
73
+ func (blder * WebhookBuilder ) WithDefaulter (defaulter admission.CustomDefaulter , opts ... admission.DefaulterOption ) * WebhookBuilder {
72
74
blder .customDefaulter = defaulter
75
+ blder .customDefaulterOpts = opts
73
76
return blder
74
77
}
75
78
@@ -194,7 +197,7 @@ func (blder *WebhookBuilder) registerDefaultingWebhook() error {
194
197
195
198
func (blder * WebhookBuilder ) getDefaultingWebhook () * admission.Webhook {
196
199
if defaulter := blder .customDefaulter ; defaulter != nil {
197
- w := admission .WithCustomDefaulter (blder .mgr .GetScheme (), blder .apiType , defaulter )
200
+ w := admission .WithCustomDefaulter (blder .mgr .GetScheme (), blder .apiType , defaulter , blder . customDefaulterOpts ... )
198
201
if blder .recoverPanic != nil {
199
202
w = w .WithRecoverPanic (* blder .recoverPanic )
200
203
}
0 commit comments