-
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
Generate a CRD with {type: string, format: date-time} #5867
Comments
I don't think that roundtripping is supported at the moment. The CRDGenerator for example does not use Jackson's See #5859 to get an overview about the missing JSONSchema properties. |
From a historical POV when we started the @matteriben do you have a specific use-case? In general, I would happily accept PRs improving on this aspect(even if not completely solving it). |
As discussed on #5870, we're curious to know if the roundtripping is something that you need or would use. And specially what's the use-case for that. Please, if you can, share details about this 🙏 |
We are attempting to use the java-generator for contract first development of an operator. The CRDs we author may reference some existing Java types (#5843) which may appear simply as For us this issue wasn't really critical since we were okay to just drop I saw the discussion about SchemaSwap on a related issue (#5866), and that got an internal discussion going on our side and we have a PR (#5885) that seems to fix both this issue and the related one. |
🎉 amazing! Is it open source?
Here you lost me... why would you want to re-generate the CRDs if you are doing contract-first? |
It will be, but it isn't yet publicly available.
Currently the most compelling use case for crd-generation seems to be quarkus dev mode. As far as I can tell |
Please let us know when you have updates!
In this case, the correct fix should be done in the Quarkus Operator SDK, cc. @metacosm |
I split this into two PRs. The initial PR now only adds the Even with support from quarkus to apply our CRDs without generating them from source, we would need to run the crd-generator on existing types, such as Affinity, and stitch together a final CRD. Generating the full CRD from the java-code, if possible, seems preferable. |
@matteriben I need to settle expectations on this one, the design goals of the generators in this project are:
If I understand correctly, what you are trying to do is a sort of "pipeline":
supporting such workflow has never been a goal of this project.
I will support any bug fix that will arise from this exercise as long as it aligns with the original design goals, and, at the same time, I encourage you to take a more radical position over code or contract, a couple of possible scenarios:
|
I have another PR here: #5917 |
I'm kind of lost as well… why would you want to re-apply the CRD if you're doing contract-first? In a contract-first scenario, it seems to me that the Quarkus Operator SDK shouldn't touch the CRD at all, since it should be, by design, outside of its control… In this situation, CRD generation should be deactivated altogether using |
@metacosm at best of my understanding, this is the missing bit: quarkiverse/quarkus-operator-sdk#867 basically the Quarkus Operator SDK only applies the generated CRD in dev mode. |
I'm not sure that this should be handled by QOSDK, to be honest. Presumably, the CRD is already defined and already applied to the cluster in a contract-first scenario. In my opinion, applying the CRD shouldn't be done automatically but only when the user is satisfied with the state the CRD is in. This isn't something that can be asserted by QOSDK. |
I don't disagree, although this functionality is provided, as of today, for |
The functionality is provided, though, to automatically apply the updated CRD when the Java code changes (and only in that case), which we can detect automatically with Quarkus. |
The Maven Plugin re-generate the source code, so, watching those files is basically the same at the best of my understanding, or am I missing something? |
The CRD is not generated via Maven in QOSDK's case, it's done via the API whenever Quarkus triggers a hot reload (and the extension determines that whatever triggered the reload affects the CRD) during dev mode. The CRD is then applied only if it has been regenerated by the extension but this only happens whenever Quarkus is running (the CRD is not applied during a build, for example). I guess we could have a marker file to indicate whether or not the CRD needs to be re-applied after Java code got regenerated whenever Quarkus starts the next time so maybe we wouldn't need to watch the CRD for changes. I haven't really used the Java generator so I'm not too familiar with how it works. Now that I think of it, maybe it could be possible to have Quarkus monitor the CRD and trigger Java code generation in dev mode. Not sure how feasible that would be or if it's even something we want to support, though. |
Just like @metacosm indicates the CRD is the externally provided contract, it's not (or shouldn't) change under any circumstance. Doesn't Quarkus provide a feature to deploy/apply any YAML file present in a given directory (e.g. JKube has something like that). |
Thanks everyone for the context. I get the motivations, let's wait for @matteriben feedback as well.
This can probably help too! |
Is your enhancement related to a problem? Please describe
I'd like to generate a CRD with a timestamp of type=string, and format=date-time.
I can generate code from a CRD with a string using date-time format, but when I generate a CRD from that code it generates something else entirely. For example:
Original CRD snippet:
Java code snippet generated from above CRD snippet:
CRD snippet generated from above Java code snippet:
Describe the solution you'd like
I'd like for CRD fields of {type=string, format=date-time} to roundtrip from CRD to Java and back to CRD.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: