@@ -37,16 +37,17 @@ import (
3737
3838// WebhookBuilder builds a Webhook.
3939type 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
5051}
5152
5253// WebhookManagedBy returns a new webhook builder.
@@ -67,9 +68,11 @@ func (blder *WebhookBuilder) For(apiType runtime.Object) *WebhookBuilder {
6768 return blder
6869}
6970
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 {
7274 blder .customDefaulter = defaulter
75+ blder .customDefaulterOpts = opts
7376 return blder
7477}
7578
@@ -194,7 +197,7 @@ func (blder *WebhookBuilder) registerDefaultingWebhook() error {
194197
195198func (blder * WebhookBuilder ) getDefaultingWebhook () * admission.Webhook {
196199 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 ... )
198201 if blder .recoverPanic != nil {
199202 w = w .WithRecoverPanic (* blder .recoverPanic )
200203 }
0 commit comments