Skip to content

Conversation

@inteon
Copy link
Member

@inteon inteon commented Nov 3, 2025

@erikgb found this really cool new linter modernize.

I tried my best to fix all issues it found.

@cert-manager-prow cert-manager-prow bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 3, 2025

Spec CertificateRequestPolicySpec `json:"spec,omitempty"`
Status CertificateRequestPolicyStatus `json:"status,omitempty"`
Spec CertificateRequestPolicySpec `json:"spec"`
Copy link
Member Author

Choose a reason for hiding this comment

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

The spec probably should not have been optional.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that we should do this, but it's technically a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

That should not be an issue imo, a CertificateRequestPolicy without Spec should have resulted in an error before too.

Status CertificateRequestPolicyStatus `json:"status,omitempty"`
Spec CertificateRequestPolicySpec `json:"spec"`
// +optional
Status CertificateRequestPolicyStatus `json:"status,omitzero"`
Copy link
Member Author

Choose a reason for hiding this comment

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

@erikgb I believe in the marshalled object, it would be cleaner to not have a status field if it is empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree.

metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata"`
Copy link
Member Author

Choose a reason for hiding this comment

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

In this KEP: https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/2335-vanilla-crd-openapi-subset-structural-schemas#metadata, it looks like the metadata field is not required.

I think it is fine to always have this field in the marshalled resource.

Copy link
Member

@erikgb erikgb left a comment

Choose a reason for hiding this comment

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

/approve

And a soft LGTM. Just a question on what looks like an unintentional change.

@inteon, can you please review cert-manager/makefile-modules#468 and cert-manager/makefile-modules#467? I believe it will make the adoption of this new linter a lot more effective.


Spec CertificateRequestPolicySpec `json:"spec,omitempty"`
Status CertificateRequestPolicyStatus `json:"status,omitempty"`
Spec CertificateRequestPolicySpec `json:"spec"`
Copy link
Member

Choose a reason for hiding this comment

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

I agree that we should do this, but it's technically a breaking change.

Status CertificateRequestPolicyStatus `json:"status,omitempty"`
Spec CertificateRequestPolicySpec `json:"spec"`
// +optional
Status CertificateRequestPolicyStatus `json:"status,omitzero"`
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree.

Items []CertificateRequestPolicy `json:"items"`
// +optional
metav1.ListMeta `json:"metadata"`

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Unintentional change?

Copy link
Member Author

Choose a reason for hiding this comment

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

what is unintentional? the extra newline?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, thanks, just verifying. I think it is OK.

@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: erikgb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2025
@erikgb erikgb requested a review from Copilot November 3, 2025 21:04
Copy link
Contributor

Copilot AI left a comment

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 modernizes the codebase by enabling the modernize linter and applying its recommendations. The changes replace deprecated Go patterns with their modern equivalents, improving code clarity and consistency with current Go best practices.

Key changes:

  • Replaced manual loop-based slice searches with slices.Contains
  • Updated interface{} to use the modern any type alias
  • Migrated from reflect.TypeOf() to the more efficient reflect.TypeFor[]()
  • Updated CRD JSON tags and added required field validation

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/internal/webhook/validator.go Simplified plugin name validation using slices.Contains
pkg/internal/approver/validation/validator.go Replaced interface{} with any in variable declaration
pkg/internal/approver/validation/serviceaccount.go Updated CEL interface methods to use any and reflect.TypeFor[]()
pkg/internal/approver/constraints/evaluator.go Updated function signature to use any instead of interface{}
pkg/apis/policy/v1alpha1/types_certificaterequestpolicy.go Updated JSON tags and added field markers for proper API validation
deploy/crds/policy.cert-manager.io_certificaterequestpolicies.yaml Added required field validation for spec field
deploy/charts/approver-policy/templates/crd-policy.cert-manager.io_certificaterequestpolicies.yaml Added required field validation for spec field
.golangci.yaml Removed exclusion rule that disabled the modernize linter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@erikgb erikgb left a comment

Choose a reason for hiding this comment

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

This looks sane to me! Thanks @inteon!

/lgtm

@cert-manager-prow cert-manager-prow bot added the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2025
@cert-manager-prow cert-manager-prow bot merged commit 79f1e31 into main Nov 7, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants