-
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
feat(crd-generator): Add support for validation rules #5788
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 this improvement, looks good to me, but I should ask to test the content of the newly generated fields 🙏
crd-generator/api/src/test/java/io/fabric8/crd/generator/v1/JsonSchemaTest.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, @baloo42 are you planning to iterate more on this?
I think that's good to go 😄 feel free to remove it from "Draft"
- Allow to define validation rules on classes - Combine validation rules from attributes and accessor methods - Combine validation rules from inherited classes and attributes/accessor methods
@andreaTP Now I'm ready. I added support for some advanced use cases. Now the only feature which is still missing is support for meta-annotations. But that's missing for the other annotations, too. Have you discussed the support of meta-annotations in the CRDGenerator in the past? |
Quality Gate failedFailed conditions |
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.
A couple of minor comments that should slightly simplify the PR, but looks very promising!
crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java
Show resolved
Hide resolved
crd-generator/api/src/test/resources/k8svalidations.samples.fabric8.io-v1.yml
Show resolved
Hide resolved
crd-generator/api/src/test/resources/k8svalidations.samples.fabric8.io-v1beta1.yml
Show resolved
Hide resolved
not sure I'm getting this one, maybe this is related: #3768 |
#3768 is something different. (But should be implemented too in my opinion) With "meta-annotations" support I mean that a user is able to combine our existing annotations to new annotations like described in the following article with JUnit annotations: Spring, for example has also support for Meta-Annotations/Composed Annotations: Is this something we want to support in the future? (Is there an easy and performant way to implement it with sundrio?) |
That's interesting, and it has not been discussed previously. |
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.
This PR LGTM, thanks again for all the help @baloo42 ! Appreciated 🙏
facade.nullable, | ||
facade.required, | ||
facade.preserveUnknownFields); | ||
|
||
addProperty(possiblyRenamedProperty, builder, possiblyUpdatedSchema, options); | ||
} | ||
|
||
List<KubernetesValidationRule> validationRules = Stream | ||
.concat(definition.getAnnotations().stream(), definition.getExtendsList().stream() | ||
.flatMap(classRef -> GetDefinition.of(classRef).getAnnotations().stream())) |
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.
I needed here a way to resolve annotations for inherited classes. Is this the right way to implement it with sundrio?
GetDefinition.of(classRef)
The issue has been created: #5823 (Some use-cases can be useful and can be implemented, some won't work) |
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
Adds support for Kubernetes validation rules to CRDGenerator:
Refers to #4367
Type of change
test, version modification, documentation, etc.)
Checklist
TODO's