-
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 #5388: Generate deterministic CRDs #5390
Fix #5388: Generate deterministic CRDs #5390
Conversation
ac54a0d
to
ba3ed8e
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.
@Donnerbart thanks a lot for taking the time to go through this!
I have a couple of questions but let me know your thoughts!
crd-generator/api/src/main/java/io/fabric8/crd/generator/DeterministicObjectMapper.java
Outdated
Show resolved
Hide resolved
crd-generator/api/src/main/java/io/fabric8/crd/generator/DeterministicObjectMapper.java
Outdated
Show resolved
Hide resolved
LGTM but I wish @metacosm can do a final review here. |
@shawkins input would be great too, at least to verify that those changes are not affecting somehow the KC operator. |
ba3ed8e
to
92c575b
Compare
I've changed the comparison for I also added more JavaDoc to the |
The license check is failing for the checked in YAML file in the test resources. I see that there are already some exclusions for test resources:
I don't want to change |
@andreaTP @Donnerbart I'll double check specifically with keycloak generation, but glancing at the changes I don't see anything that is too concerning. However there is a lot of complexity that doesn't seem to be needed - with all of the updates to the mapper the only unsorted array in the complex json schema that I see are enum properties. Also printer columns are already sorted by path. Could we consider reducing the changes to 3ea9b08 Or do you have more examples of where arrays / collections end up unsorted in the jsonschema? |
71e6705
to
dc66d70
Compare
@shawkins That's a great finding! I've double checked our complex example, since there were for sure more nondeterministic fields. Looks like these were all properties, that are now sorted via So indeed, with the correctly sorted enums that quite hacky way of adding the collection serializer is not needed anymore. I also cleaned up the complex example, by adding simplified, but stable versions of the K8s models being used. This still provides enough properties, that were unsorted before, but won't break on future changes on the K8s model classes. |
dc66d70
to
bc86bb1
Compare
@Donnerbart the CI failure on Win seems to be relevant, probably the encoding of the file is causing a difference. This approach might also play nicer with the License check, e.g. you can include the License header in the committed file and skip it during the comparison. |
@andreaTP Yeah, when I saw Windows I had the same thought. Will look into this first thing tomorrow (it's already end of workday for me). I guess you don't want any helper dependency like Apache Commons or so in the test scope, so I'll write that comparison by hand. Will also look into adding the license header then. |
Thanks for getting back, no rush!
I (personally) have no issues with adding helper dependencies to the test scope ... |
dde5d5a
to
1c11ac2
Compare
ee5dd11
to
40af55d
Compare
|
40af55d
to
a1bbd92
Compare
crd-generator/api/src/test/java/io/fabric8/crd/generator/ResourcesTest.java
Outdated
Show resolved
Hide resolved
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, just one minor comment.
crd-generator/api/src/main/java/io/fabric8/crd/generator/CRDGenerator.java
Show resolved
Hide resolved
a1bbd92
to
6af16f3
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs 100.0% Coverage The version of Java (11.0.20) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17. |
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!
Description
Fixes #5388
I'm not sure if you want the provided
Complex
custom resource example as is in your code base, since it has nestedObjectMetaData
,StatefulSetSpec
andServiceSpec
and is tested against a checked in YAML file. So on every change on those K8s resources, the checked in file needs to be adapted (for example, non-breaking changes like adding new fields).Type of change
test, version modification, documentation, etc.)
Checklist