refactor: use omitzero for struct fields in API types#1117
refactor: use omitzero for struct fields in API types#1117kahirokunn wants to merge 1 commit intoknative:mainfrom
Conversation
Go 1.24 introduced the omitzero JSON tag option which properly handles struct fields. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: kahirokunn The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1117 +/- ##
=======================================
Coverage 93.33% 93.33%
=======================================
Files 35 35
Lines 1005 1005
=======================================
Hits 938 938
Misses 53 53
Partials 14 14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@kahirokunn: The following test failed, say
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
What problem are you trying to solve with |
|
There are no particular issues either. |
Go 1.24 introduced the
omitzeroJSON tag option which properly handles struct fields.omitemptyhas no effect on non-pointer struct fields. the struct is never considered "empty" byencoding/json, so the tag is silently ignored.omitzerochecks the zero value correctly for these types.This commit replaces
omitemptywithomitzeroon all non-pointer struct fields across the v1alpha1 API types (Ingress,Certificate,ClusterDomainClaim,ServerlessServiceand their List types).Changes
omitemptywithomitzeroon embeddedObjectMeta/ListMetaand top-levelSpec/Statusstruct fieldsomitemptywithomitzeroonintstr.IntOrStringfield inHTTP01Challenge/kind cleanup
Release Note
Docs