Skip to content

Commit 3cc1910

Browse files
committed
Linting
1 parent 48a1c08 commit 3cc1910

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

pkg/builder/webhook.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func WebhookManagedBy[T runtime.Object](m manager.Manager, object T) *WebhookBui
6464

6565
// WithDefaulter takes an admission.CustomDefaulter interface, a MutatingWebhook with the provided opts (admission.DefaulterOption)
6666
// will be wired for this type.
67-
// deprecated: Use WithAdmissionDefaulter instead.
67+
// Deprecated: Use WithAdmissionDefaulter instead.
6868
func (blder *WebhookBuilder[T]) WithDefaulter(defaulter admission.CustomDefaulter, opts ...admission.DefaulterOption) *WebhookBuilder[T] {
6969
blder.customDefaulter = defaulter
7070
blder.customDefaulterOpts = opts
@@ -79,7 +79,7 @@ func (blder *WebhookBuilder[T]) WithAdmissionDefaulter(defaulter admission.Defau
7979
}
8080

8181
// WithValidator takes a admission.CustomValidator interface, a ValidatingWebhook will be wired for this type.
82-
// deprecated: Use WithAdmissionValidator instead.
82+
// Deprecated: Use WithAdmissionValidator instead.
8383
func (blder *WebhookBuilder[T]) WithValidator(validator admission.CustomValidator) *WebhookBuilder[T] {
8484
blder.customValidator = validator
8585
return blder
@@ -254,9 +254,6 @@ func (blder *WebhookBuilder[T]) getDefaultingWebhook() *admission.Webhook {
254254
w = admission.WithDefaulter(blder.mgr.GetScheme(), blder.defaulter, blder.customDefaulterOpts...)
255255
} else if customDefaulter := blder.customDefaulter; customDefaulter != nil {
256256
w = admission.WithCustomDefaulter(blder.mgr.GetScheme(), blder.apiType, customDefaulter, blder.customDefaulterOpts...)
257-
if blder.recoverPanic != nil {
258-
}
259-
return w
260257
}
261258
if w != nil && blder.recoverPanic != nil {
262259
w = w.WithRecoverPanic(*blder.recoverPanic)
@@ -298,12 +295,11 @@ func (blder *WebhookBuilder[T]) getValidatingWebhook() *admission.Webhook {
298295
w = admission.WithValidator(blder.mgr.GetScheme(), validator)
299296
} else if customValidator := blder.customValidator; customValidator != nil {
300297
w = admission.WithCustomValidator(blder.mgr.GetScheme(), blder.apiType, customValidator)
301-
return w
302298
}
303299
if w != nil && blder.recoverPanic != nil {
304300
w = w.WithRecoverPanic(*blder.recoverPanic)
305301
}
306-
return nil
302+
return w
307303
}
308304

309305
func (blder *WebhookBuilder[T]) registerConversionWebhook() error {

pkg/webhook/admission/defaulter_custom.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Defaulter[T runtime.Object] interface {
3636
Default(ctx context.Context, obj T) error
3737
}
3838

39+
// CustomDefaulter defines functions for setting defaults on resources.
3940
// Deprecated: CustomDefaulter is deprecated, use Defaulter instead
4041
type CustomDefaulter = Defaulter[runtime.Object]
4142

@@ -53,7 +54,7 @@ func DefaulterRemoveUnknownOrOmitableFields(o *defaulterOptions) {
5354
o.removeUnknownOrOmitableFields = true
5455
}
5556

56-
// WithDefaulter creates a new Webhook for a CustomDefaulter interface.
57+
// WithDefaulter creates a new Webhook for a Defaulter interface.
5758
func WithDefaulter[T runtime.Object](scheme *runtime.Scheme, defaulter Defaulter[T], opts ...DefaulterOption) *Webhook {
5859
options := &defaulterOptions{}
5960
for _, o := range opts {
@@ -69,6 +70,7 @@ func WithDefaulter[T runtime.Object](scheme *runtime.Scheme, defaulter Defaulter
6970
}
7071
}
7172

73+
// WithCustomDefaulter creates a new Webhook for a CustomDefaulter interface.
7274
func WithCustomDefaulter(scheme *runtime.Scheme, obj runtime.Object, defaulter CustomDefaulter, opts ...DefaulterOption) *Webhook {
7375
options := &defaulterOptions{}
7476
for _, o := range opts {

pkg/webhook/admission/validator_custom.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
// Warnings represents warning messages.
3131
type Warnings []string
3232

33-
// CustomValidator defines functions for validating an operation.
33+
// Validator defines functions for validating an operation.
3434
// The object to be validated is passed into methods as a parameter.
3535
type Validator[T runtime.Object] interface {
3636
// ValidateCreate validates the object on creation.
@@ -49,7 +49,8 @@ type Validator[T runtime.Object] interface {
4949
ValidateDelete(ctx context.Context, obj T) (warnings Warnings, err error)
5050
}
5151

52-
// deprecated: CustomValidator is deprecated, use Validator instead
52+
// CustomValidator defines functions for validating an operation.
53+
// Deprecated: CustomValidator is deprecated, use Validator instead
5354
type CustomValidator = Validator[runtime.Object]
5455

5556
// WithValidator creates a new Webhook for validating the provided type.
@@ -63,7 +64,8 @@ func WithValidator[T runtime.Object](scheme *runtime.Scheme, validator Validator
6364
}
6465
}
6566

66-
// deprecated: WithCustomValidator is deprecated, use WithValidator instead
67+
// WithCustomValidator creates a new Webhook for a CustomValidator.
68+
// Deprecated: WithCustomValidator is deprecated, use WithValidator instead
6769
func WithCustomValidator(scheme *runtime.Scheme, obj runtime.Object, validator CustomValidator) *Webhook {
6870
return &Webhook{
6971
Handler: &validatorForType[runtime.Object]{

pkg/webhook/alias.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ import (
2323

2424
// define some aliases for common bits of the webhook functionality
2525

26-
// CustomDefaulter defines functions for setting defaults on resources.
27-
type CustomDefaulter = admission.CustomDefaulter
28-
29-
// CustomValidator defines functions for validating an operation.
30-
type CustomValidator = admission.CustomValidator
31-
3226
// AdmissionRequest defines the input for an admission handler.
3327
// It contains information to identify the object in
3428
// question (group, version, kind, resource, subresource,

0 commit comments

Comments
 (0)