-
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
Add crd-generator and java-generator support for Format annotation #5885
base: main
Are you sure you want to change the base?
Conversation
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.
The CRD-generator changes are good to me(maybe @baloo42 is interested in reviewing).
I see the motivations for those changes but we should not emit SchemaFrom
and/or SchemaSwap
from the java-generator.
It's fine to generate the Format
annotations though.
java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JObject.java
Outdated
Show resolved
Hide resolved
related #5881 |
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.
The implementation looks good to me regarding the CRD-Generator. It also fits to #5881. (My prototype looks the same but I hold it back because I prefer @Schema
to avoid annotation explosion). But it's possible to implement both: If format
is defined by @Format
and @Schema
, the format value from @Schema
would win (which would break roundtrips again).
I only would suggest to make it more clear that format
can be used for other formats than date-time
.
Regarding java-generator: I'm not able to say something in depth because I'm not actively using it. But to me it looks like a breaking change for some users.
generator-annotations/src/main/java/io/fabric8/generator/annotation/Format.java
Show resolved
Hide resolved
4fefc0b
to
a992e9f
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.
Beside of the nitpick in the docs it looks now good to me regarding the CRD-Generator
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.
Although I don't see much value for the java-generator
part, I'm fine with those changes, thanks 👍
c310f8d
to
f200acc
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.
LGTM, thx!
I see the use case for this when using the CRD Generator, at the moment you cannot inject a custom format. |
There is built-in support for the format within Jackson, which is now wired up into the prospective changes in my next state branch. There may be some usability limitations with that, so it's possible that a Format annotation will still make sense. If not we'll just deprecate it in 7 like some of the other annotations. @matteriben and others - the current progress on what I'd like to see as the 7.0 state of the crd generator is at Ideally we could start to minimize the 6.x version changes, or at least get a first class branch going for the next state so that it can be targeted with pull requests for support like this as well. |
After looking at the planned changes it doesn't make sense to me to add features / annotations to v6 of the CRD-Generator anymore. Any new feature would have to be replaced by a new implementation based on Jackson. I also see, that the crd-generator-apt module will be removed. Do you plan a replacement? Can I help you with v7 instead? e.g. with some feedback on comments or implementing some of the other missing features. I would suggest to create a crd-generator-v7-development branch in the kubernetes-client project. |
Yes, we have discussed adding a maven plugin and a gradle plugin for non-quarkus / josdk based usage. Maybe something utilizing jandax for discovery?
Absolutely. I'll create that branch, and we can how it can be adapted to your needs. I had just sent a message to other team members desribing the state of things, let me know what you may want to work on and we can sync up our efforts - Where things stand:
Next steps:
Related:
|
@matteriben @baloo42 @andreaTP here's an upstream development branch https://github.com/fabric8io/kubernetes-client/tree/crd-generator-v7-development |
Thanks for the detailed answer. I think we should move the further discussion out of this PR: |
So let's merge this one then?? |
Quality Gate passedIssues Measures |
@shawkins, sorry, it was unclear but the question was specifically for you. It's unclear to me if this should be moved forward as is or not given your previous comments. |
Let's have @baloo42 and @matteriben check if their use cases are satisfied by the v2 logic already. If so, then we can close this pr. If not, then we'll probably want to retarget to v2, rather than introducing additional v1 support. |
My use case does appear to be handled as desired in the v2 branch. |
After testing v2 it seems like the new implementation covers a lot more cases for format but unfortunatly not all. Not covered:
But is that worth to introduce an own annotation? Maybe we can cover that with a single |
@baloo42 in addition to any general proposal, it would help to capture where each of those could have additional support in jackson, or with the v2 generator as well. Anywhere the type alone is sufficient, we should easily cover. |
If I understand you correct, you mean that e.g. Inet4Address could be mapped to:
I think this can be a solution but we must be aware of that Jackson contains sometimes some overriding logic with a shape: This might require some more code but I don't expect too much of such cases, so I'm fine with that strategy. |
Sure, ideally all of this should be considered in the serializer. The InetAddressSerializer should be overriding acceptJsonFormatVisitor and passing the relevant JsonValueFormat - this is what DateTimeSerializer is doing. We can of course add handling on our side for it, but I'd prefer to push things upstream where possible. |
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.
LGTM
Description
Type of change
test, version modification, documentation, etc.)
Checklist