fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift
http://fabric8.io
Apache License 2.0
3.35k stars 1.45k forks source link

CRD-Generator: Overview about validation constraints / Kubernetes OpenAPI schema properties #5859

Open baloo42 opened 3 months ago

baloo42 commented 3 months ago

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.

Current state

Annotation Description
com.fasterxml.jackson.annotation.JsonProperty The field is named after the provided value instead of looking up the java field name
com.fasterxml.jackson.annotation.JsonPropertyDescription The provided text is be embedded in the description of the field
com.fasterxml.jackson.annotation.JsonIgnore The field is ignored
io.fabric8.crd.generator.annotation.PreserveUnknownFields The field have x-kubernetes-preserve-unknown-fields: true defined
com.fasterxml.jackson.annotation.JsonAnyGetter The corresponding object have x-kubernetes-preserve-unknown-fields: true defined
com.fasterxml.jackson.annotation.JsonAnySetter The corresponding object have x-kubernetes-preserve-unknown-fields: true defined
io.fabric8.generator.annotation.Min The field defines a validation min
io.fabric8.generator.annotation.Max The field defines a validation max
io.fabric8.generator.annotation.Pattern The field defines a validation pattern
io.fabric8.generator.annotation.Nullable The field is marked as nullable
io.fabric8.generator.annotation.Required The field is marked as required
io.fabric8.generator.annotation.ValidationRule The field or object is validated by a CEL rule (x-kubernetes-validation-rules)
io.fabric8.crd.generator.annotation.SchemaFrom The field type for the generation is the one coming from the annotation
io.fabric8.crd.generator.annotation.SchemaSwap Similar to SchemaFrom, but can be applied at any point in the class hierarchy
io.fabric8.crd.generator.annotation.Annotations Additional annotations in metadata
io.fabric8.crd.generator.annotation.Labels Additional labels in metadata
io.fabric8.crd.generator.annotation.PrinterColumn Customize columns shown by the kubectl get command

Missing schema properties

Property Description
minLength/maxLength see #5836
minItems/maxItems see #5836
minProperties/maxProperties see #5836
exclusiveMinimum / exclusiveMaximum see #5868
multipleOf see #5881
x-kubernetes-map-type see #5881
x-kubernetes-list-type see #5881
x-kubernetes-list-map-keys see #5881
x-kubernetes-embedded-resource see #5881
format see #5881, #5867 (PR: #5885)
externalDocs see #5881
example see #5881

Other missing properties

Property Description
conversion see #5794 (includes NoneConversion and WebhookConversion), PR: #5875
categories see #5795

Not Supported / Useless

andreaTP commented 2 months ago

Quick note: this is a pretty large change and we can prepare for it, but I would like to roll it out when we start working on version 7.X of this repo.

baloo42 commented 2 months ago

When do you plan to release v7 ?

Can we chat somewhere on this topic?

baloo42 commented 2 months ago

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".

andreaTP commented 2 months ago

Can we chat somewhere on this topic?

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.