Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Differentiate between missing and empty arrays #190

Open
dhirajsb opened this issue Jan 12, 2017 · 3 comments
Open

Differentiate between missing and empty arrays #190

dhirajsb opened this issue Jan 12, 2017 · 3 comments

Comments

@dhirajsb
Copy link
Member

The model currently initializes all array fields with new ArrayList<...>, which makes it difficult to know whether the field was empty or not set at all in the original json/yaml source.

This causes a serious issue in k8 client JSON patch request, since it generates a different request for the two cases.

If the array is missing, it generates a patch request to add a new array if it exists and to set the element at '0' if its empty respectively.

K8 model should distinguish the two use cases, by lazily initializing all collections on add calls.

@jimmidyson
Copy link
Contributor

This is a serious issue that if we fix it properly as suggested would break backwards compatibility for consumers that rely on these being initialised. I cannot think of any functionality other than patch that this causes problems with & if that's the case should we defer the "proper" fix until v2 of the model (which I have in the works btw) & do the hack in kube client to handle empty arrays as @dhirajsb has already done?

@dhirajsb
Copy link
Member Author

@jimmidyson that's also my assessment so far. It has only broken json patch, due to the way OpenShift and I suspect K8s ignore empty arrays.
For example, if one tries to add an empty array using {{oc edit..}} it is actually dropped altogether, hence the approach I took to fixing it for json patch.

@piyush-garg
Copy link
Contributor

piyush-garg commented Jan 24, 2018

#280 is related to this as far as I can conclude.

@iocanel iocanel removed their assignment Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants