-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Fixing the omitempty tag #8338
Fixing the omitempty tag #8338
Conversation
@@ -435,7 +435,7 @@ type AWSElasticBlockStoreVolumeSource struct { | |||
// Ex. "ext4", "xfs", "ntfs" | |||
// TODO: how do we prevent errors in the filesystem from compromising the machine | |||
// TODO: why omitempty if required? |
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.
Remove TODO
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.
Removed.
@@ -200,26 +200,26 @@ type VolumeSource struct { | |||
// to see the host machine. Most containers will NOT need this. |
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.
On https://github.com/nikhiljindal/kubernetes/blob/omitEmpty/pkg/api/v1beta3/types.go#L191
VolumeSource
json:",inline,omitempty"``
inline fields shouldn't have omitempty
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.
Also, everywhere, except PodTemplateSpec and Binding, ObjectMeta should not be tagged with omitempty.
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.
Why is ObjectMeta not omitempty? All the fields in ObjectMeta are omitempty.
Not making it omitempty will just force users to include "metadata:{}" in their configs.
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.
Updated VolumeSource
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.
Users have to specify either name or generateName, in post, put, and patch, and it will be returned by get.
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.
It's ok to leave them all omitempty for now, but I can't think of a scenario where metadata would be absent. We could maybe extract the name from the URLs on some operations, but I don't think we do that currently.
@@ -1010,7 +1009,7 @@ type ServicePort struct { | |||
// If this is a string, it will be looked up as a named port in the | |||
// target Pod's container ports. If this is not specified, the value | |||
// of Port is used (an identity map). | |||
TargetPort util.IntOrString `json:"targetPort" description:"the port to access on the pods targeted by the service; defaults to the service port"` | |||
TargetPort util.IntOrString `json:"targetPort,omitempty" description:"the port to access on the pods targeted by the service; defaults to the service port"` |
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.
Another github annoyance -- I can't comment on arbitrary lines. :-(
ServiceAccount.Secrets should have omitempty:
https://github.com/nikhiljindal/kubernetes/blob/omitEmpty/pkg/api/v1beta3/types.go#L1052
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.
Done
Thanks much. I reviewed the whole v1beta3 file. Please make equivalent changes to v1. |
Updated both v1beta3 and v1 as per comments, modulo one question regarding ObjectMeta. |
LGTM |
Fixes #7730 and #6841
Fixing the omitempty tag for v1beta3 and v1 APIs.