Skip to content
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] Implement SchemaSwap #3797

Merged
merged 2 commits into from Mar 2, 2022
Merged

Conversation

andreaTP
Copy link
Member

@andreaTP andreaTP commented Feb 3, 2022

Description

This is a Draft implementation of SchemaSwap.
The annotation serves to enable the use-case where you want to generate a valid CRD from a model that you don't own.

e.g.:
The model comes as a dependency on the classpath and you cannot add SchemaFrom annotations to it.

Issue found in (cc. @vmuzikar):
keycloak/keycloak#9759

I'm opening this PR as Draft to start the conversation regarding pros/cons and alternatives to this approach.
PRO:

  • it enables to inject the equivalent of SchemaFrom annotations in a hierarchy without punctual changes
  • the type checker is mostly preventing big issues
  • [not implemented yet] we can implement a guard to throw an exception in case of fields/classes not found

CONS:

  • the CRD api module cannot be easily executed anymore outside an AnnotationProcessor (the REFLECTION_CONTEXT doesn't preserve Annotations at the class level cc. @iocanel )
  • Adding the APT Context subtly breaks the extraction of the Map value type

I'm happy to gather feedback and alternative proposals! cc. @metacosm @iocanel

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@andreaTP
Copy link
Member Author

@iocanel would you be able to release a new version of sundrio containing the fix? 🙏 Thanks in advance!

@andreaTP andreaTP force-pushed the schema-swap branch 2 times, most recently from 864c6ae to 3b8b7a2 Compare February 16, 2022 14:42
@andreaTP andreaTP marked this pull request as ready for review February 16, 2022 14:45
@andreaTP
Copy link
Member Author

Ready for review 🎉 cc. @metacosm
I'll add the documentation for this new annotation as soon as we agree this is the way to proceed.

Copy link
Collaborator

@metacosm metacosm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@andreaTP
Copy link
Member Author

Thanks @metacosm 🎉 , added the corresponding documentation.
It should be ready for final review/merge @manusa

@sonarcloud
Copy link

sonarcloud bot commented Feb 24, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

74.7% 74.7% Coverage
0.0% 0.0% Duplication

@manusa manusa added the 5.12.x Backportable tentative label Mar 1, 2022
@andreaTP
Copy link
Member Author

andreaTP commented Mar 2, 2022

To backport this change to 5.12 we would need support from @iocanel 🙏
We need this PR backported to the 0.50 series of sundrio.

@manusa manusa added this to the 6.0.0 milestone Mar 2, 2022
@manusa manusa merged commit 394b98a into fabric8io:master Mar 2, 2022
@manusa manusa mentioned this pull request Apr 5, 2022
11 tasks
@manusa manusa modified the milestones: 6.0.0, 5.12.2 Apr 5, 2022
@manusa manusa removed the 5.12.x Backportable tentative label Apr 5, 2022
@manusa manusa mentioned this pull request Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/crd-generator Related to the CRD generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants