Skip to content

Commit 74d8791

Browse files
committed
refactor: use omitzero instead of omitempty for struct fields
Go 1.24 introduced the omitzero JSON tag option which properly handles struct fields. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 965e7c3 commit 74d8791

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

pkg/apis/networking/v1alpha1/certificate_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ type Certificate struct {
3636
// Standard object's metadata.
3737
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
3838
// +optional
39-
metav1.ObjectMeta `json:"metadata,omitempty"`
39+
metav1.ObjectMeta `json:"metadata,omitzero"`
4040

4141
// Spec is the desired state of the Certificate.
4242
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
4343
// +optional
44-
Spec CertificateSpec `json:"spec,omitempty"`
44+
Spec CertificateSpec `json:"spec,omitzero"`
4545

4646
// Status is the current state of the Certificate.
4747
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
4848
// +optional
49-
Status CertificateStatus `json:"status,omitempty"`
49+
Status CertificateStatus `json:"status,omitzero"`
5050
}
5151

5252
// Verify that Certificate adheres to the appropriate interfaces.
@@ -70,7 +70,7 @@ type CertificateList struct {
7070
// Standard object's metadata.
7171
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
7272
// +optional
73-
metav1.ListMeta `json:"metadata,omitempty"`
73+
metav1.ListMeta `json:"metadata,omitzero"`
7474

7575
// Items is the list of `Certificate`.
7676
Items []Certificate `json:"items"`
@@ -121,7 +121,7 @@ type HTTP01Challenge struct {
121121
ServiceNamespace string `json:"serviceNamespace,omitempty"`
122122

123123
// ServicePort is the port of the service to serve HTTP01 challenge requests.
124-
ServicePort intstr.IntOrString `json:"servicePort,omitempty"`
124+
ServicePort intstr.IntOrString `json:"servicePort,omitzero"`
125125
}
126126

127127
// GetStatus retrieves the status of the Certificate. Implements the KRShaped interface.

pkg/apis/networking/v1alpha1/domainclaim_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ type ClusterDomainClaim struct {
3131
// Standard object's metadata.
3232
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
3333
// +optional
34-
metav1.ObjectMeta `json:"metadata,omitempty"`
34+
metav1.ObjectMeta `json:"metadata,omitzero"`
3535

3636
// Spec is the desired state of the ClusterDomainClaim.
3737
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
3838
// +optional
39-
Spec ClusterDomainClaimSpec `json:"spec,omitempty"`
39+
Spec ClusterDomainClaimSpec `json:"spec,omitzero"`
4040
}
4141

4242
// Check that we can create OwnerReferences to a ClusterDomainClaim.
@@ -50,7 +50,7 @@ type ClusterDomainClaimList struct {
5050
// Standard object metadata.
5151
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
5252
// +optional
53-
metav1.ListMeta `json:"metadata,omitempty"`
53+
metav1.ListMeta `json:"metadata,omitzero"`
5454

5555
// Items is the list of ClusterDomainClaim objects.
5656
Items []ClusterDomainClaim `json:"items"`

pkg/apis/networking/v1alpha1/ingress_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ type Ingress struct {
3939
// Standard object's metadata.
4040
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
4141
// +optional
42-
metav1.ObjectMeta `json:"metadata,omitempty"`
42+
metav1.ObjectMeta `json:"metadata,omitzero"`
4343

4444
// Spec is the desired state of the Ingress.
4545
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
4646
// +optional
47-
Spec IngressSpec `json:"spec,omitempty"`
47+
Spec IngressSpec `json:"spec,omitzero"`
4848

4949
// Status is the current state of the Ingress.
5050
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
5151
// +optional
52-
Status IngressStatus `json:"status,omitempty"`
52+
Status IngressStatus `json:"status,omitzero"`
5353
}
5454

5555
// Verify that Ingress adheres to the appropriate interfaces.
@@ -73,7 +73,7 @@ type IngressList struct {
7373
// Standard object metadata.
7474
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
7575
// +optional
76-
metav1.ListMeta `json:"metadata,omitempty"`
76+
metav1.ListMeta `json:"metadata,omitzero"`
7777

7878
// Items is the list of Ingress objects.
7979
Items []Ingress `json:"items"`

pkg/apis/networking/v1alpha1/serverlessservice_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ type ServerlessService struct {
3838
// Standard object's metadata.
3939
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
4040
// +optional
41-
metav1.ObjectMeta `json:"metadata,omitempty"`
41+
metav1.ObjectMeta `json:"metadata,omitzero"`
4242

4343
// Spec is the desired state of the ServerlessService.
4444
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
4545
// +optional
46-
Spec ServerlessServiceSpec `json:"spec,omitempty"`
46+
Spec ServerlessServiceSpec `json:"spec,omitzero"`
4747

4848
// Status is the current state of the ServerlessService.
4949
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
5050
// +optional
51-
Status ServerlessServiceStatus `json:"status,omitempty"`
51+
Status ServerlessServiceStatus `json:"status,omitzero"`
5252
}
5353

5454
// Verify that ServerlessService adheres to the appropriate interfaces.
@@ -72,7 +72,7 @@ type ServerlessServiceList struct {
7272
// Standard object's metadata.
7373
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
7474
// +optional
75-
metav1.ListMeta `json:"metadata,omitempty"`
75+
metav1.ListMeta `json:"metadata,omitzero"`
7676

7777
// Items is the list of ServerlessService.
7878
Items []ServerlessService `json:"items"`

0 commit comments

Comments
 (0)