Closed wlan0 closed 6 years ago
We don't control serialization of kubernetes api types. ReplicaSetStatus.Replicas doesn't have omitempty
set so that's why the zero appears. You'll see similar things across the board if you just deserialize and reserialize a k8s api object.
CreationTimestamp uses metav1.Time, which has custom serialization code that specifically uses the string "null"
, so that would require upstream changes as well.
I know how the kubernetes types work.
You are setting the value to an uninitialized but allocated object
Status has an omitempty
(https://github.com/kubernetes/api/blob/master/extensions/v1beta1/types.go#L802), and won't show up if you leave replicas as nil. When you set the replicas to an empty object, the Status object loses its Zero value status and shows up making my file look ugly.
https://github.com/kubernetes/api/blob/master/extensions/v1beta1/types.go#L853 Status.Replicas isn't a pointer, though.
You're right - Is there no way to omit that field when the Status is zero valued?
I believe so. I think that part is outside our control.
we can access the text section of the go program and change (should mprotect PROT_WRITE for the appropriate pages in the runtime) the compiled type signature in the running go program to do this. I have a working example.
Would not recommend doing this though.
Closing because the replicas issue was solved by using pointers - ezpz
On conversion and reversion, the Zero value fields with values like "null" or replicas: 0 should not be printed.
This was from my conversion from kube to koki first and then back.
status should'nt have shown similarly, creationTimeStamp key should'nt have shown in the output