-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
Support top-level enums in CRDs #856
Conversation
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
675a5fb
to
ed8f12b
Compare
Codecov Report
@@ Coverage Diff @@
## master #856 +/- ##
=======================================
Coverage 70.56% 70.57%
=======================================
Files 59 61 +2
Lines 4212 4244 +32
=======================================
+ Hits 2972 2995 +23
- Misses 1240 1249 +9
Continue to review full report at Codecov.
|
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'm not sure I'd encourage anyone to actually use this, but I also can't really justify forbidding it entirely.
I'm a little bit surprised, what are the disadvantages that you see when using a top-level enum? |
I'd guesstimate that most CRDs will have at least some fields that are common between variants, and using enums will make it harder to transition to those later. You could do something like: struct FooKind {
shared: String,
#[serde(flatten)]
method: FooKindMethod,
}
enum FooKindMethod {
Foo { ... },
Bar { ... },
} But that feels like it would get clunky and unclear to document which fields are mutually exclusive with which. |
as an addendum to what Teo is saying: It's a funny thing about the versioning of kubernetes crds that most people are almost never bumping the apiVersion and instead keep making tiny-non-breaking changes to it (adding new options, merely marking fields as deprecated) until some major release. Enums make that slightly harder. But I don't see any other reasons why you would want to be careful with such a spec. |
Thanks for your feedback! |
Agreed. Edge-case, but has potential. CI wise, I think github was struggling earlier, so it looks like you might need to push again or do the DCO thing (the action has details). |
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
a64014e
to
c6d1b6a
Compare
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
622c009
to
8805251
Compare
There is something strange going in the clippy check. |
Signed-off-by: Sebastian Bernauer <sebastian.bernauer@stackable.de>
Checks are blocked by briansmith/ring#1469 |
Oh, ok, whatever. We can fix-forward on clippy. I'l just merge this now that DCO and all important checks are green. |
Thanks a lot! |
Currently only top-level structs are supported. Enums are supported as well (with some limitations) but not at top-level.
Motivation
I want to specify a CRD with a top-level enum
Solution
Added support for top-level enums