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

Some omitempty usage modifications #410

Merged
merged 1 commit into from
Oct 24, 2016
Merged

Some omitempty usage modifications #410

merged 1 commit into from
Oct 24, 2016

Conversation

zhouhao3
Copy link

Optional fields should be added omitempty
Signed-off-by: zhouhao zhouhao@cn.fujitsu.com

@@ -17,34 +17,34 @@ package v1
// ImageConfig defines the execution parameters which should be used as a base when running a container using an image.
type ImageConfig struct {
// User defines the username or UID which the process in the container should run as.
User string `json:"User"`
User string `json:"User,omitepty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

“omitepty” → “omitempty”.

@wking
Copy link
Contributor

wking commented Oct 21, 2016

Besides the typos, 5a318bf looks good to me.

Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
@philips
Copy link
Contributor

philips commented Oct 24, 2016

LGTM

Approved with PullApprove

1 similar comment
@vbatts
Copy link
Member

vbatts commented Oct 24, 2016

LGTM

Approved with PullApprove

@vbatts vbatts merged commit 5be4024 into opencontainers:master Oct 24, 2016
@zhouhao3 zhouhao3 deleted the test-zz branch October 25, 2016 01:07
@stevvooe
Copy link
Contributor

stevvooe commented Feb 6, 2017

omitempty has nothing to do with REQUIRED vs OPTIONAL.

Please revert this change.

@stevvooe stevvooe mentioned this pull request Feb 6, 2017
@zhouhao3
Copy link
Author

zhouhao3 commented Feb 7, 2017

@stevvooe In addition, after reading your discussion, I am not very clear when omitempty should be used, that is, why do you think this change is wrong, I did not see the specific provisions.

@stevvooe
Copy link
Contributor

stevvooe commented Feb 7, 2017

omitempty influences when Go json package emits values for zero-valued fields. Please read https://golang.org/pkg/encoding/json/. It should not be used to try to comply with the required and optional provisions of the specification, as simply doesn't do that.

Typically, omitempty should be used on every field unless you want it to emit a zero-value. An example might be if you want to have an empty slice be emitted, rather than omitting the field. I don't think there are any cases in OCI where it make sense to not have omitempty.

@zhouhao3
Copy link
Author

zhouhao3 commented Feb 7, 2017

@stevvooe So. I can't revert it,because the content have changed since it was merged. Would I need to reopen a PR to restore it?

@wking
Copy link
Contributor

wking commented Feb 7, 2017 via email

zhouhao3 pushed a commit to zhouhao3/image-spec that referenced this pull request Feb 7, 2017
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
zhouhao3 pushed a commit to zhouhao3/image-spec that referenced this pull request Feb 8, 2017
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
zhouhao3 pushed a commit to zhouhao3/image-spec that referenced this pull request Feb 8, 2017
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
zhouhao3 pushed a commit to zhouhao3/image-spec that referenced this pull request Feb 8, 2017
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
zhouhao3 pushed a commit to zhouhao3/image-spec that referenced this pull request Feb 8, 2017
Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants