-
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
CRD generator ignores @Accessors
annotations
#4934
Comments
is the |
Good question! @shawkins ? |
@andreaTP yes those are lombok annotations |
I don't think we should support lombok annotations out-of-the-box in the CRD generator. |
here we have the list of all of the supported annotations, anything else is implicitly not supported, as far as I can tell ... |
Agreed, I thought that this was a Jackson annotation I didn't know about. I'd be in favor of closing this as rejected, then. |
It's just surprising from a usage perspective. Without the JsonProperty everything works as expected with Jackson, or even the sundrio builder generation. So the CRD logic is doing something different. |
This is correct, the CRD logic is not extracting the name using the logic from IIRC |
@shawkins do you still think we should do any action in this context? The problem here is that, if we start supporting In this specific case, we have to appreciate the fact that |
Does this boil down to what order the annotation processing is done in? That is if you worked against the already processed source that contained the actual getter and setter would the crd name be as expected? |
So, here we are challenging the assumption of extracting the property name from the field name as opposed to the getter/setters. I'll let @metacosm and @manusa break the tie here, whatever the outcome is I propose we document accordingly the decision taken. |
It is, it's just different than Jackson.
Sounds good. |
Using explicit accessors results in the field being omitted entirely from the CRD:
|
this looks like a bug indeed, it should be easily reproducible in the unit tests though. |
The problem with the accessor detection is that it's pretty dumb: the accessors have to be named after the field and prefixed either by Without an associated field that we can rely on to be matched to the accessor methods and without adding too many specific corner cases, we can't be sure the methods are supposed to be properties or just synthetic fields that should not be in the generated CRD. Looking at the code, a human can easily make that decision, however, without looking at the method implementation, it's a lot less easy. So the question here becomes whether or not we want to support this corner case where the field is named after a Java keyword and is prefixed by |
To be clear, it's probably easy to implement. The question is whether we want to add this feature or not. |
I agree this is a stretch, but we should probably emit a warning in this case. |
Problem is detecting the case to emit a warning is probably equivalent to supporting the "feature" in term of complexity. |
This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions! |
Describe the bug
The CRD generator seemed to ignore accessor methods and just used the field name.
Environment
Quarkus operator extension 4.0.7
Possible Solution
The workaround was to add a
JsonProperty
to the field.See operator-framework/java-operator-sdk#1792
Fabric8 Kubernetes Client version
5.12.4
Steps to reproduce
With a class like
The generated crd contained
_field
, rather thanfield
as the property name.Expected behavior
Generated CRD should output
field
instead of_field
Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.25.3@latest
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: