Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ linters:
paths: [third_party, builtin$, examples$]
warn-unused: true
settings:
modernize:
disable:
# TODO(erikgb): Enable when we know how to do this correctly in API types
- omitzero
staticcheck:
checks: ["all", "-ST1000", "-ST1001", "-ST1003", "-ST1005", "-ST1012", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1001", "-QF1003", "-QF1008"]
enable:
Expand Down
13 changes: 8 additions & 5 deletions api/v1beta1/googlecasclusterissuer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ import (
// +kubebuilder:subresource:status
// GoogleCASClusterIssuer is the Schema for the googlecasclusterissuers API
type GoogleCASClusterIssuer struct {
metav1.TypeMeta `json:",inline"`
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.

Spec GoogleCASIssuerSpec `json:"spec,omitempty"`
Status v1alpha1.IssuerStatus `json:"status,omitempty"`
Spec GoogleCASIssuerSpec `json:"spec"`
// +optional
Status v1alpha1.IssuerStatus `json:"status,omitzero"`
}

func (vi *GoogleCASClusterIssuer) GetConditions() []metav1.Condition {
Expand All @@ -50,7 +52,8 @@ var _ v1alpha1.Issuer = &GoogleCASClusterIssuer{}
// GoogleCASClusterIssuerList contains a list of GoogleCASClusterIssuer
type GoogleCASClusterIssuerList struct {
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.
Items []GoogleCASClusterIssuer `json:"items"`
}

Expand Down
15 changes: 9 additions & 6 deletions api/v1beta1/googlecasissuer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type GoogleCASIssuerSpec struct {

// 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.


// CertificateTemplate is specific certificate template to
// use. Omit to not specify a template
Expand All @@ -56,11 +56,13 @@ type GoogleCASIssuerSpec struct {
// +kubebuilder:subresource:status
// GoogleCASIssuer is the Schema for the googlecasissuers API
type GoogleCASIssuer struct {
metav1.TypeMeta `json:",inline"`
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.

Spec GoogleCASIssuerSpec `json:"spec,omitempty"`
Status v1alpha1.IssuerStatus `json:"status,omitempty"`
Spec GoogleCASIssuerSpec `json:"spec"`
// +optional
Status v1alpha1.IssuerStatus `json:"status,omitzero"`
}

func (vi *GoogleCASIssuer) GetConditions() []metav1.Condition {
Expand All @@ -77,7 +79,8 @@ var _ v1alpha1.Issuer = &GoogleCASIssuer{}
// GoogleCASIssuerList contains a list of GoogleCASIssuer
type GoogleCASIssuerList struct {
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.
Items []GoogleCASIssuer `json:"items"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ spec:
- type
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.

type: object
served: true
storage: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ spec:
- type
x-kubernetes-list-type: map
type: object
required:
- spec
type: object
served: true
storage: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ spec:
- type
x-kubernetes-list-type: map
type: object
required:
- spec
type: object
served: true
storage: true
Expand Down
2 changes: 2 additions & 0 deletions deploy/crds/cas-issuer.jetstack.io_googlecasissuers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ spec:
- type
x-kubernetes-list-type: map
type: object
required:
- spec
type: object
served: true
storage: true
Expand Down
Loading