-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(model): use Object instead of KubernetesResource for raw types #6333
Conversation
5a1306f
to
1a9ec4c
Compare
Just wanted to talk broadly on the usage of AnyType, RawExtension, GenericKuberenetesResource, and what is being done here with object and the KubernetesDeserializer. AnyType - can be a replacement for where we had previously been using JsonNode and Map types, but is not currently directly used in our models. Also serves as a base type for RawExtension and IntOrString. Is not directly needed by the KubernetesDeserializer. v2 CRD Mappings: It's clear that these mappings are not bi-directional (I haven't check if the logic knows about AnyType), so round-tripping can result in a different object model. With this pr we're mapping kube's raw extension to Object directly with the KubernetesDeserializer. If we're good with this approach we can consider deprecating the RawExtension class and recommending instead that users with custom resources take the same approach. The one thing that will look bad about this is KubernetesDeserializer is in an internal package. We'll also need to update the CRD generator to understand this convention. Also if user for whatever reason a user puts an untyped value in the Object field, it will be deserialized as a RawExtension - which doesn't work well if we want to put that on the path to deprecation. We should also update the CRD generation logic to understand this convention, and consider making a similar change to the java generator. AnyType could similarly be deprecated if we consider its usage synonomous with Object without the KuberenetsDeserializer - currently that will just map to an object property without preserve uknown. |
Signed-off-by: Marc Nuri <marc@marcnuri.com>
1a9ec4c
to
dc2dcde
Compare
I'm extracting your comment into an issue for further discussion (especially for CRDv2).
I'm not 100% sure that removing the intermediate RawExtension class will allow for a complete deserialization-serialization roundtrip (this is working now, see tests in kustomize module -and others-) |
It won't currently because of RawExtension's usage in the KubernetesDeserializer, but it's not needed if we fully embrace the usage of Object with KubernetesDeserializer. |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
Fixes #6332
Type of change
test, version modification, documentation, etc.)
Checklist