Fix unstructured metadata accessors to respect omitempty semantics#67635
Conversation
|
Does this need a "action required" release note? |
How is this even passing golint? There are so many linting errors in there. 🤷♀️ /lint |
k8s-ci-robot
left a comment
There was a problem hiding this comment.
@nikhita: 2 warnings.
Details
In response to this:
Some packages in hack/.golint_failures are passing golint. Please remove them. staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructuredHow is this even passing golint? There are so many linting errors in there. 🤷♀️
/lint
Instructions 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/test-infra repository.
There was a problem hiding this comment.
Golint naming: receiver name u should be consistent with previous receiver name obj for Unstructured. More info.
There was a problem hiding this comment.
Golint naming: receiver name u should be consistent with previous receiver name obj for Unstructured. More info.
ObjectMeta has fields with omitempty json tags. This means that when the fields have zero values, they should not be persisted in the object. Before this commit, some of the metadata accessors for unstructured objects did not respect these semantics i.e they would persist a field even if it had a zero value. This commit updates the accessors so that the field is removed from the unstructured object map if it contains a zero value.
039005a to
dabd56f
Compare
|
/lint |
k8s-ci-robot
left a comment
There was a problem hiding this comment.
@nikhita: 2 unresolved warnings and 6 new warnings.
Details
In response to this:
/lint
Instructions 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/test-infra repository.
There was a problem hiding this comment.
Golint comments: exported method Unstructured.EachListItem should have comment or be unexported. More info.
There was a problem hiding this comment.
None of the methods in that file have comments and it doesn't really make sense to add to each one either. :/
There was a problem hiding this comment.
Golint comments: exported method Unstructured.UnstructuredContent should have comment or be unexported. More info.
There was a problem hiding this comment.
Golint comments: exported method Unstructured.SetUnstructuredContent should have comment or be unexported. More info.
There was a problem hiding this comment.
Golint comments: exported method Unstructured.GetObjectKind should have comment or be unexported. More info.
There was a problem hiding this comment.
Golint comments: exported method Unstructured.IsList should have comment or be unexported. More info.
There was a problem hiding this comment.
Golint comments: exported method Unstructured.ToList should have comment or be unexported. More info.
|
don't feed the linter... it'll just want another cookie :) |
0eb1f27 to
dabd56f
Compare
:) I removed the last commit which tried to fix the golint errors. It's back to how it was before in the previous PR. |
|
Regarding the linting: kubernetes/hack/verify-golint.sh Lines 75 to 76 in 816f2a4 Looks like this completely ignores all errors if it sees a |
|
If golint sees a kubernetes/hack/verify-golint.sh Line 77 in 816f2a4 |
|
this LGTM. @sttts, was there a way we were collecting dev-related release notes for client-go/apimachinery usage? I'm not sure this change makes sense as a user-facing release note, but seems worthwhile to capture for users of the go libraries |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, nikhita The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
manually. :/
I was doing the manual release note process work for client-go anyway, so I'll take care of the release note for this one. |
|
Quick update here: there is a golint fix now - #67675 🎉 |
|
This LGTM. One question: do we need to check zero values for |
No valid serialized object has those set to empty values, so I don't think so |
|
Automatic merge from submit-queue (batch tested with PRs 67298, 67518, 67635, 67673). If you want to cherry-pick this change to another branch, please follow the instructions here. |
@liggitt we don't have prow support. But we usually use |
Fixes #67541
Fixes #48211
Fixes #49075
Follow up of #67562
ObjectMetahas fields withomitemptyjson tags. This means that when the fields have zero values, they should not be persisted in the object.Before this PR, some of the metadata accessors for unstructured objects did not respect these semantics i.e they would persist a field even if it had a zero value.
This PR updates the accessors so that the field is removed from the unstructured object map if it contains a zero value.
/sig api-machinery
/kind bug
/area custom-resources
/cc sttts liggitt yue9944882 roycaihw
/assign sttts liggitt
Release note: