-
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
fix: crd-gen includes only enum values and discard enum fields #4230
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.
Thanks a lot for the fix @leoandrea7 , unfortunately, we need a better check as, extending the test in this way:
public enum AnnotatedEnum {
non("N"),
@JsonProperty("oui") es("O");
private final String abbreviation;
private AnnotatedEnum def;
AnnotatedEnum(String abbreviation) {
this.abbreviation = abbreviation;
}
AnnotatedEnum(AnnotatedEnum def) {
this.abbreviation = null;
this.def = def;
}
public String getAbbreviation() {
return abbreviation;
}
public AnnotatedEnum getDefault() {
return non;
}
}
breaks the test.
I took a look at this issue and cannot find a proper check to correctly include/exclude enum's instances. Specifically given the test here: We include all the needed properties, but we don't know how to discriminate actual values of the Enum from other methods/accessos/constructors. Maybe @metacosm or @iocanel can help. Alternatively, it should be enough to "workaround" this issue by considering the |
@leoandrea7 couldn't find any way to discriminate the actual enum values from other properties :-( |
|
@leoandrea7 right, but this is not generic enough to distinguish enum values from the rest as demonstrated in this comment: i.e. Feel free to try out my snippet and you will get the relevant test to fail. |
@andreaTP you are absolutely right...The problem is that TypeDef class does not have a method that return just enum values..I tried to fetch enum with |
@andreaTP After some thought, I think your test case with an enum containing a field of the same type as the enum itself is a very infrequent case. For now it would be better to merge this solution which solves most of the use cases and I could add in the docs of the crd-gen a new section (titled limitation or known problems) in which I specify that this particular case is not yet supported. Then if in the future the sundrio library will introduce a specific method to retrieve only the values of an enum through the TypeDef class then we will also solve the use case you have proposed. This merge would solve most of the use cases for enums containing fields. What do you think? |
I don't think this case is infrequent, and anyhow, unfortunately, it's semantically incorrect. Meanwhile, we can add the necessary information in Sundrio cc. @iocanel and move on from there. |
Submitted #4294 should provide a workaround also for this issue. |
Hi #4294 has been merged. Is this PR providing something else? |
@manusa , yes, this PR is providing something different, but, to have a robust implementation we need to bubble up information changing |
@shawkins do you mind fixing the conflicts? |
Kudos, SonarCloud Quality Gate passed! |
Description
Fix #4225
Type of change
test, version modification, documentation, etc.)
Checklist