-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Add support for untagged enums in CRDs #1028
Conversation
7b7516f
to
e922be3
Compare
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
e922be3
to
440f60b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work fine in my testing. My one concern is that this is basically the same logic as the existing one_of flattening (and seems to be ~93% copy/pasted). Could we factor it out to a separate function that we reuse?
After that I'd be happy to merge.
Refactored it out to a separate function, please have a look |
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
7b02713
to
e1d5406
Compare
Co-authored-by: Teo Klestrup Röijezon <teo@nullable.se> Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Co-authored-by: Teo Klestrup Röijezon <teo@nullable.se> Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Co-authored-by: Teo Klestrup Röijezon <teo@nullable.se> Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Co-authored-by: Teo Klestrup Röijezon <teo@nullable.se> Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
ce82308
to
9840511
Compare
kube-core/src/schema.rs
Outdated
subschemas: &mut Vec<Schema>, | ||
common_obj: &mut Option<Box<ObjectValidation>>, | ||
instance_type: &mut Option<SingleOrVec<InstanceType>>, | ||
allow_if_equal: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can get rid of allow_if_equal
now and just assume that across the board?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That changes the current implementation for oneOf but sounds reasonable. Adopted!
c7ab486
to
5cc72fc
Compare
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
5cc72fc
to
7d6ee75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
Motivation
We want to use untagged enums in our CRDs. This allows us to better validate the users input, without the user realizing that under the hood enums are used.
Solution
Extending the
Visitor for StructuralSchemaRewriter
to rewriteanyOf
clauses so that they are accepted by the k8s api-server.