Skip to content

chore: enabling back unparam - #2091

Open
prometherion wants to merge 1 commit into
projectcapsule:mainfrom
prometherion:chore/unparam
Open

chore: enabling back unparam#2091
prometherion wants to merge 1 commit into
projectcapsule:mainfrom
prometherion:chore/unparam

Conversation

@prometherion

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
Copilot AI lite review requested due to automatic review settings August 19, 2026 12:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 unparam in .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., bool instead 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.Tenant is unused here; with unparam enabled 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 old and decoder are unused in this handler; with unparam enabled 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.Decoder is unused in this update handler; with unparam enabled 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.Decoder is unused in this update handler; with unparam enabled 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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants