-
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
CRDGenerator: Overview about validation constraints / Kubernetes OpenAPI schema properties #5859
Comments
Quick note: |
When do you plan to release v7 ? Can we chat somewhere on this topic? |
My general suggestion on this topic is to create issues for each property first. Those issues should describe the solution (intended annotation(s), addditional structural validations) to get a clear picture of what the overall solution could look like. If we have an agreement on the overall solution, we can prioritize and maybe also group it a little bit. Please keep also in mind, that all missing properties from above could be implemented in a non breaking way. But if you think this would be too dangerous, we can also talk about a new side-project, where we can try out things faster. Something like "Next-CRD-Generator". |
Yes, we are meeting every Wednesday (the next one is tomorrow), my private email is public on my GH profile, please reach me and I'll forward an invite, @matteriben feel free to do the same as you are working on overlapping concerns. |
Not sure if my comment is relevant, but I'll go ahead and make it here before creating a new issue. What I would like to see besides more comprehensive support for validation constraints, which is what this issue seems to be about, is interoperability with other annotations that do similar things with other libraries. For example, I would like to be able to use the corresponding Jakarta Bean Validation annotations to attach My request comes from the fact that I'm already using Jakarta Bean Validation for certain objects that I want to include inside of a CRD. The same applies also to the |
The problem with using Jakarta Bean Validation Annotations is, that they have slightly different semantics than constraints in Kubernetes. This was one of the reasons to introduce own annotations. As far as I know, support for those annotations is not planned at the moment. But this might be reconsidered if the rewritten CRD-Generator v2 is fully in place (release v7). |
@baloo42 I'm not sure what the plan is for v2, but I noticed that the CRD generator currently uses the Jackson JSONSchema module, which its own maintainers do not recommend to use. I ended up implementing a custom CRD generator that uses victools/jsonschema-generator, and that project has a plugin framework with various modules to enable support for third-party annotations (Jakarta, Swagger, etc). Maybe a similar approach can be adopted for v2. |
The v2 one does also https://github.com/fabric8io/kubernetes-client/tree/main/crd-generator/api-v2/src/main/java/io/fabric8/crdv2/generator
It's been touched on in a couple of other discussions why it was the simplest choice to stick with jackson jsonSchema. If / when we have to move to Jackson v3 support (it's been in the works for 7 years) we can revisit this. Have a look at the new implementation - it is more straight-forward than when we were consuming the sundrio model and is likely more adaptable to your needs.
It is certainly possible to make the annotation support extensible - there is some support for that in the JSONSchema module as well. It wouldn't be much work to expose that via the CRD generator. Or if you want to contribute an alternative implementation based upon victools that could be looked at as well. |
Is your enhancement related to a problem? Please describe
At the moment the CRD-Generator does not allow to set all possible details to the resulting CRDs.
Describe the solution you'd like
The CRD-Generator supports all Kubernetes features to describe a CRD.
Additional context
This issue aims to provide an overview of the current state and what we plan to implement.
Introduce specific annotations for the generators #4348
(Discussion: Add support for Min, Max, Pattern and Nullable on CRD generator fields #4298)
Important
This overview is now targeting api-v2!
Current state
com.fasterxml.jackson.annotation.JsonProperty
com.fasterxml.jackson.annotation.JsonPropertyDescription
description
of the fieldcom.fasterxml.jackson.annotation.JsonIgnore
io.fabric8.crd.generator.annotation.PreserveUnknownFields
x-kubernetes-preserve-unknown-fields: true
definedcom.fasterxml.jackson.annotation.JsonAnyGetter
x-kubernetes-preserve-unknown-fields: true
definedcom.fasterxml.jackson.annotation.JsonAnySetter
x-kubernetes-preserve-unknown-fields: true
definedio.fabric8.generator.annotation.Min
minimum
valueio.fabric8.generator.annotation.Max
maximum
valueio.fabric8.generator.annotation.Size
minLength
,minItems
,minProperties
, ...)io.fabric8.generator.annotation.Pattern
pattern
io.fabric8.generator.annotation.Nullable
nullable
io.fabric8.generator.annotation.Required
required
io.fabric8.generator.annotation.ValidationRule
io.fabric8.crd.generator.annotation.SchemaFrom
io.fabric8.crd.generator.annotation.SchemaSwap
io.fabric8.crd.generator.annotation.Annotations
annotations
inmetadata
io.fabric8.crd.generator.annotation.Labels
labels
inmetadata
io.fabric8.crd.generator.annotation.PrinterColumn
kubectl get
command.io.fabric8.crd.generator.annotation.AdditionalPrinterColumn
kubectl get
command.io.fabric8.crd.generator.annotation.SelectableField
io.fabric8.crd.generator.annotation.AdditionalSelectableField
io.fabric8.kubernetes.model.annotation.SpecReplicas
specReplicaPath
io.fabric8.kubernetes.model.annotation.StatusReplicas
statusReplicaPath
io.fabric8.kubernetes.model.annotation.LabelSelector
labelSelectorPath
Missing schema properties
minLength
/maxLength
minItems
/maxItems
minProperties
/maxProperties
exclusiveMinimum
/exclusiveMaximum
multipleOf
#5881x-kubernetes-map-type
#5881, #6668x-kubernetes-list-type
#5881, #6669x-kubernetes-list-map-keys
#5881, #6669x-kubernetes-embedded-resource
#5881format
#5881,#5867 (PR: #5885 - On Hold)
externalDocs
#5881, #6667example
#5881Other missing properties
conversion
PR: #5875categories
Not Supported / Useless
The text was updated successfully, but these errors were encountered: