Skip to content

Conversation

@erikgb
Copy link
Member

@erikgb erikgb commented Nov 8, 2025

Applying the principles laid out in cert-manager/approver-policy#740.

Signed-off-by: Erik Godding Boye <[email protected]>
@cert-manager-prow cert-manager-prow bot added the dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. label Nov 8, 2025
@erikgb erikgb requested a review from Copilot November 8, 2025 11:42
@cert-manager-prow cert-manager-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 8, 2025
x-kubernetes-list-type: map
type: object
required:
- 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.

I believe this makes sense, and is an oversight, even if it's technically a breaking change.

Copy link

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 updates the JSON struct tags for Kubernetes API types to align with modern best practices, specifically migrating from omitempty to omitzero where appropriate and making the spec field required in the CRD schemas.

Key changes:

  • Migrated optional struct fields from omitempty to omitzero for better zero-value handling
  • Made the spec field required in CRD definitions for both GoogleCASIssuer and GoogleCASClusterIssuer
  • Removed the linter exception that previously disabled the omitzero modernization check

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
api/v1beta1/googlecasissuer_types.go Updated JSON struct tags for GoogleCASIssuer and GoogleCASIssuerList types to use omitzero and removed omitempty where appropriate
api/v1beta1/googlecasclusterissuer_types.go Updated JSON struct tags for GoogleCASClusterIssuer and GoogleCASClusterIssuerList types to use omitzero and removed omitempty where appropriate
deploy/crds/cas-issuer.jetstack.io_googlecasissuers.yaml Added required validation for the spec field in the CRD schema
deploy/crds/cas-issuer.jetstack.io_googlecasclusterissuers.yaml Added required validation for the spec field in the CRD schema
deploy/charts/google-cas-issuer/templates/crd-cas-issuer.jetstack.io_googlecasissuers.yaml Added required validation for the spec field in the Helm chart CRD template
deploy/charts/google-cas-issuer/templates/crd-cas-issuer.jetstack.io_googlecasclusterissuers.yaml Added required validation for the spec field in the Helm chart CRD template
.golangci.yaml Removed the modernize linter exception that disabled omitzero checks

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

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

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

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

The metadata field for Kubernetes resources should use json:\"metadata,omitempty\" according to Kubernetes API conventions. The metadata field is automatically populated by the API server and an empty struct should be omitted during serialization. Removing omitempty deviates from standard Kubernetes patterns and could cause issues with marshaling/unmarshaling.

Copilot uses AI. Check for mistakes.
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// +optional
metav1.ListMeta `json:"metadata"`
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

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

The metadata field for Kubernetes list types should use json:\"metadata,omitempty\" according to Kubernetes API conventions. This is the standard pattern used across all Kubernetes API types and ensures proper serialization behavior.

Suggested change
metav1.ListMeta `json:"metadata"`
metav1.ListMeta `json:"metadata,omitempty"`

Copilot uses AI. Check for mistakes.
metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata"`
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

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

The metadata field for Kubernetes resources should use json:\"metadata,omitempty\" according to Kubernetes API conventions. The metadata field is automatically populated by the API server and an empty struct should be omitted during serialization. Removing omitempty deviates from standard Kubernetes patterns and could cause issues with marshaling/unmarshaling.

Copilot uses AI. Check for mistakes.
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// +optional
metav1.ListMeta `json:"metadata"`
Copy link

Copilot AI Nov 8, 2025

Choose a reason for hiding this comment

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

The metadata field for Kubernetes list types should use json:\"metadata,omitempty\" according to Kubernetes API conventions. This is the standard pattern used across all Kubernetes API types and ensures proper serialization behavior.

Suggested change
metav1.ListMeta `json:"metadata"`
metav1.ListMeta `json:"metadata,omitempty"`

Copilot uses AI. Check for mistakes.
// Credentials is a reference to a Kubernetes Secret Key that contains Google Service Account Credentials
// +optional
Credentials cmmetav1.SecretKeySelector `json:"credentials,omitempty"`
Credentials cmmetav1.SecretKeySelector `json:"credentials,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.

According to the Kubernetes API conventions, this optional field should have been a pointer field without omitzero.

@erikgb
Copy link
Member Author

erikgb commented Nov 8, 2025

/cc @inteon

@cert-manager-prow cert-manager-prow bot requested a review from inteon November 8, 2025 11:47
@inteon
Copy link
Member

inteon commented Nov 12, 2025

Thanks @erikgb!

/approve
/lgtm

@cert-manager-prow cert-manager-prow bot added the lgtm Indicates that a PR is ready to be merged. label Nov 12, 2025
@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon

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 12, 2025
@cert-manager-prow cert-manager-prow bot merged commit a680972 into main Nov 12, 2025
12 checks passed
@cert-manager-prow cert-manager-prow bot deleted the modernize-omitzero branch November 12, 2025 09:51
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