Skip to content
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

Merged
merged 1 commit into from
May 18, 2015
Merged

Fixing the omitempty tag #8338

merged 1 commit into from
May 18, 2015

Conversation

nikhiljindal
Copy link
Contributor

Fixes #7730 and #6841

Fixing the omitempty tag for v1beta3 and v1 APIs.

@nikhiljindal
Copy link
Contributor Author

@bgrant0607

@@ -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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove TODO

Copy link
Contributor Author

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.
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated VolumeSource

Copy link
Member

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.

Copy link
Member

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"`
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@bgrant0607
Copy link
Member

Thanks much. I reviewed the whole v1beta3 file. Please make equivalent changes to v1.

@nikhiljindal
Copy link
Contributor Author

Updated both v1beta3 and v1 as per comments, modulo one question regarding ObjectMeta.

@bgrant0607
Copy link
Member

LGTM

@bgrant0607 bgrant0607 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2015
vmarmol added a commit that referenced this pull request May 18, 2015
@vmarmol vmarmol merged commit bf912e0 into kubernetes:master May 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Fix omitempty tags
4 participants