@@ -36,15 +36,16 @@ import (
3636
3737// WebhookBuilder builds a Webhook.
3838type WebhookBuilder struct {
39- apiType runtime.Object
40- customDefaulter admission.CustomDefaulter
41- customValidator admission.CustomValidator
42- gvk schema.GroupVersionKind
43- mgr manager.Manager
44- config * rest.Config
45- recoverPanic * bool
46- logConstructor func (base logr.Logger , req * admission.Request ) logr.Logger
47- err error
39+ apiType runtime.Object
40+ customDefaulter admission.CustomDefaulter
41+ customDefaulterOpts []admission.DefaulterOption
42+ customValidator admission.CustomValidator
43+ gvk schema.GroupVersionKind
44+ mgr manager.Manager
45+ config * rest.Config
46+ recoverPanic * bool
47+ logConstructor func (base logr.Logger , req * admission.Request ) logr.Logger
48+ err error
4849}
4950
5051// WebhookManagedBy returns a new webhook builder.
@@ -65,9 +66,11 @@ func (blder *WebhookBuilder) For(apiType runtime.Object) *WebhookBuilder {
6566 return blder
6667}
6768
68- // WithDefaulter takes an admission.CustomDefaulter interface, a MutatingWebhook will be wired for this type.
69- func (blder * WebhookBuilder ) WithDefaulter (defaulter admission.CustomDefaulter ) * WebhookBuilder {
69+ // WithDefaulter takes an admission.CustomDefaulter interface, a MutatingWebhook with the provided opts (admission.DefaulterOption)
70+ // will be wired for this type.
71+ func (blder * WebhookBuilder ) WithDefaulter (defaulter admission.CustomDefaulter , opts ... admission.DefaulterOption ) * WebhookBuilder {
7072 blder .customDefaulter = defaulter
73+ blder .customDefaulterOpts = opts
7174 return blder
7275}
7376
@@ -170,7 +173,7 @@ func (blder *WebhookBuilder) registerDefaultingWebhook() {
170173
171174func (blder * WebhookBuilder ) getDefaultingWebhook () * admission.Webhook {
172175 if defaulter := blder .customDefaulter ; defaulter != nil {
173- w := admission .WithCustomDefaulter (blder .mgr .GetScheme (), blder .apiType , defaulter )
176+ w := admission .WithCustomDefaulter (blder .mgr .GetScheme (), blder .apiType , defaulter , blder . customDefaulterOpts ... )
174177 if blder .recoverPanic != nil {
175178 w = w .WithRecoverPanic (* blder .recoverPanic )
176179 }
0 commit comments