chore: enabling back unparam - #2091
Open
prometherion wants to merge 1 commit into
Open
Conversation
Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR re-enables the unparam golangci-lint linter and refactors multiple controllers/webhooks to remove (or stop threading through) parameters that are no longer used, reducing signature noise and keeping handlers aligned with current usage.
Changes:
- Re-enable
unparamin.golangci.yaml. - Remove unused parameters from various controller and webhook helper methods (e.g., dropping unused
context.Context,client.Client,admission.Request). - Simplify some internal helper APIs to return simpler results (e.g.,
boolinstead of(bool, error)where no error is produced).
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/api/processor/processor_func.go | Simplifies prune-deletion decision helper to return bool only. |
| internal/webhook/tenant/validation/storageclass_regex.go | Stops passing unused request context into validation. |
| internal/webhook/tenant/validation/rule_validator.go | Removes unused admission request plumb-through from rule validation flow. |
| internal/webhook/tenant/validation/rolebindings_regex.go | Simplifies regex validation to not require decoder/request. |
| internal/webhook/tenant/validation/required_metdata_regex.go | Removes unused admission request dependency from validation. |
| internal/webhook/tenant/validation/ingressclass_regex.go | Removes unused admission request dependency from validation. |
| internal/webhook/tenant/validation/hostname_regex.go | Removes unused admission request dependency from validation. |
| internal/webhook/tenant/validation/forbidden_annotations_regex.go | Removes unused admission request dependency from validation. |
| internal/webhook/tenant/validation/containerregistry_regex.go | Removes unused admission request dependency from validation. |
| internal/webhook/namespace/validation/cordoning.go | Drops unused client parameter from cordoning validation call chain. |
| internal/webhook/generic/replications.go | Removes unused reader/recorder wiring for delete/update path. |
| internal/webhook/cfg/validation.go | Removes unused admission request from config validation handler. |
| internal/webhook/cfg/serviceaccount.go | Removes unused admission request from serviceaccount config handler. |
| internal/webhook/cfg/owners.go | Removes unused admission request from owners config handler. |
| internal/controllers/tls/utils.go | Drops unused ctx from webhook SAN resolution. |
| internal/controllers/tls/manager.go | Updates call site for SAN helper signature change. |
| internal/controllers/tenant/status.go | Removes unused list options from object-name listing helper. |
| internal/controllers/tenant/namespaces.go | Drops unused ctx from namespace metadata reconciliation helper. |
| internal/controllers/tenant/metadata.go | Simplifies ensureMetadata to not return an always-nil error / unused ctx. |
| internal/controllers/tenant/manager.go | Updates ensureMetadata call sites after signature change. |
| internal/controllers/resources/collect.go | Drops unused ctx/client/index from raw/generator item processing helpers. |
| internal/controllers/resourcepools/pool_controller.go | Removes unused ctx/log params and simplifies namespace gathering return type. |
| internal/controllers/resourcepools/pool_controller_test.go | Updates test to match finalize signature change. |
| internal/controllers/resourcepools/claim_controller.go | Drops unused ctx from pool allocation helper. |
| internal/controllers/admission/validating.go | Drops unused ctx from webhook generation helper. |
| internal/controllers/admission/mutating.go | Drops unused ctx from webhook generation helper. |
| .golangci.yaml | Enables unparam by removing it from the disabled linter list. |
Suppressed comments (4)
internal/webhook/tenant/validation/storageclass_regex.go:61
old *capsulev1beta2.Tenantis unused here; withunparamenabled it should be marked as intentionally unused (or used).
func (h *storageClassRegexHandler) OnUpdate(
_ client.Client,
_ client.Reader,
tnt *capsulev1beta2.Tenant,
old *capsulev1beta2.Tenant,
_ admission.Decoder,
_ events.EventRecorder,
) handlers.Func {
internal/webhook/tenant/validation/containerregistry_regex.go:61
- Both
oldanddecoderare unused in this handler; withunparamenabled they should be marked as intentionally unused (or used).
func (h *containerRegistryRegexHandler) OnUpdate(
_ client.Client,
_ client.Reader,
tnt *capsulev1beta2.Tenant,
old *capsulev1beta2.Tenant,
decoder admission.Decoder,
_ events.EventRecorder,
) handlers.Func {
internal/webhook/tenant/validation/hostname_regex.go:61
decoder admission.Decoderis unused in this update handler; withunparamenabled it should be marked as intentionally unused (or used).
func (h *hostnameRegexHandler) OnUpdate(
_ client.Client,
_ client.Reader,
tnt *capsulev1beta2.Tenant,
_ *capsulev1beta2.Tenant,
decoder admission.Decoder,
_ events.EventRecorder,
) handlers.Func {
internal/webhook/tenant/validation/rule_validator.go:75
decoder admission.Decoderis unused in this update handler; withunparamenabled it should be marked as intentionally unused (or used).
func (h *RuleValidationHandler) OnUpdate(
c client.Client,
reader client.Reader,
tnt *capsulev1beta2.Tenant,
old *capsulev1beta2.Tenant,
decoder admission.Decoder,
_ events.EventRecorder,
) handlers.Func {
return func(ctx context.Context, _ admission.Request) *admission.Response {
if response := h.handle(tnt); response != nil {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
26
to
31
| func (h *storageClassRegexHandler) OnCreate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| tnt *capsulev1beta2.Tenant, | ||
| decoder admission.Decoder, | ||
| _ events.EventRecorder, |
Comment on lines
26
to
32
| func (h *containerRegistryRegexHandler) OnCreate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| tnt *capsulev1beta2.Tenant, | ||
| decoder admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { |
Comment on lines
26
to
32
| func (h *hostnameRegexHandler) OnCreate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| tnt *capsulev1beta2.Tenant, | ||
| decoder admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { |
Comment on lines
54
to
61
| func (h *ingressClassRegexHandler) OnUpdate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| tnt *capsulev1beta2.Tenant, | ||
| old *capsulev1beta2.Tenant, | ||
| decoder admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { |
Comment on lines
54
to
61
| func (h *requiredMetadataHandler) OnUpdate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| tnt *capsulev1beta2.Tenant, | ||
| old *capsulev1beta2.Tenant, | ||
| decoder admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { |
Comment on lines
38
to
+46
| func (h *RuleValidationHandler) OnCreate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| tnt *capsulev1beta2.Tenant, | ||
| decoder admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { | ||
| return func(_ context.Context, req admission.Request) *admission.Response { | ||
| if err := h.handle(tnt, req); err != nil { | ||
| return func(context.Context, admission.Request) *admission.Response { | ||
| if err := h.handle(tnt); err != nil { |
Comment on lines
57
to
+68
| @@ -65,14 +65,13 @@ func (h *cordoningHandler) OnUpdate( | |||
| tnt *capsulev1beta2.Tenant, | |||
| ) handlers.Func { | |||
| return func(ctx context.Context, req admission.Request) *admission.Response { | |||
| return h.validate(ctx, req, c, user, ns, recorder, tnt) | |||
| return h.validate(ctx, req, user, ns, recorder, tnt) | |||
Comment on lines
56
to
66
| func (h *validationHandler) OnUpdate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| cfg *capsulev1beta2.CapsuleConfiguration, | ||
| old *capsulev1beta2.CapsuleConfiguration, | ||
| _ admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { | ||
| return func(_ context.Context, req admission.Request) *admission.Response { | ||
| return h.handle(cfg, req) | ||
| return func(context.Context, admission.Request) *admission.Response { | ||
| return h.handle(cfg) | ||
| } |
Comment on lines
48
to
58
| func (h *serviceAccountHandler) OnUpdate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| cfg *capsulev1beta2.CapsuleConfiguration, | ||
| old *capsulev1beta2.CapsuleConfiguration, | ||
| _ admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { | ||
| return func(_ context.Context, req admission.Request) *admission.Response { | ||
| return h.handle(cfg, req) | ||
| return func(context.Context, admission.Request) *admission.Response { | ||
| return h.handle(cfg) | ||
| } |
Comment on lines
49
to
59
| func (h *ownerHandler) OnUpdate( | ||
| _ client.Client, | ||
| _ client.Reader, | ||
| cfg *capsulev1beta2.CapsuleConfiguration, | ||
| old *capsulev1beta2.CapsuleConfiguration, | ||
| _ admission.Decoder, | ||
| _ events.EventRecorder, | ||
| ) handlers.Func { | ||
| return func(_ context.Context, req admission.Request) *admission.Response { | ||
| return h.handle(cfg, req) | ||
| return func(context.Context, admission.Request) *admission.Response { | ||
| return h.handle(cfg) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.