-
Notifications
You must be signed in to change notification settings - Fork 35
Enable omitzero modernize linter rule #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"` | ||||||
|
|
||||||
| 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 { | ||||||
|
|
@@ -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"` | ||||||
|
||||||
| metav1.ListMeta `json:"metadata"` | |
| metav1.ListMeta `json:"metadata,omitempty"` |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"` | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
|
|
||||||
| // CertificateTemplate is specific certificate template to | ||||||
| // use. Omit to not specify a template | ||||||
|
|
@@ -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"` | ||||||
|
||||||
|
|
||||||
| 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 { | ||||||
|
|
@@ -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"` | ||||||
|
||||||
| metav1.ListMeta `json:"metadata"` | |
| metav1.ListMeta `json:"metadata,omitempty"` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,6 +155,8 @@ spec: | |
| - type | ||
| x-kubernetes-list-type: map | ||
| type: object | ||
| required: | ||
| - spec | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
metadatafield for Kubernetes resources should usejson:\"metadata,omitempty\"according to Kubernetes API conventions. Themetadatafield is automatically populated by the API server and an empty struct should be omitted during serialization. Removingomitemptydeviates from standard Kubernetes patterns and could cause issues with marshaling/unmarshaling.