-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Serializing struct field to nil #257
Comments
@jingxu97 Can you help us here? kubernetes/kubernetes@85f030c For us this breaks k8s 1.6 deployment with Istio. Details are in the referenced issue. |
Why is it necessary to omit the field during marshalling? Normally adding a new field doesn't break backwards compatibility. Decoder will just ignore the unknown fields. I also tried marshalling with the standard json encoder:
The output is |
Here's what happens. We take k8s objects, read them with client-go 1.7, serialize with client-go 1.7, and then send them to k8s 1.6 with |
The error message pasted in istio/old_pilot_repo#975 is from kubectl, not generated by apiserver. What if you do |
I believe it would work, but we have to support other cloud providers for now, who are still on 1.6 and have 1.6 apiservers. |
client-go is working as expected. client-go doesn't guarantee compatibility with kubectl.
|
That's unfortunate. What's your recommendation for k8s JSON processing library that's backwards compatible? |
The golang standard library behaves the same, so i don't think there will be a library that does what you want. Do you know why the field is not omitted even though the field has the |
omitempty cannot be applied to struct field. if it was a pointer, it would work. |
@kyessenov indeed the API is wrong, but it has to be fixed in kubernetes rather than in client-go. According to the api-convention.md, "Therefore, we ask that pointers always be used with optional fields that do not have a built-in nil value." Hence, |
Field
sizeLimit
defined here https://godoc.org/k8s.io/kubernetes/pkg/api#EmptyDirVolumeSource, can never be nil. How do I invoke the special k8s serializer to make it omit from the resulting JSON/YAML?The text was updated successfully, but these errors were encountered: