-
-
Notifications
You must be signed in to change notification settings - Fork 375
Closed
Labels
derivekube-derive proc_macro relatedkube-derive proc_macro related
Description
It would be really cool if we had a way to create declarative openapi validation rules ala:
- https://book.kubebuilder.io/reference/generating-crd.html
- https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#validation
e.g. something like:
#[derive(OpenapiValidation, Deserialize, Serialize, Clone)]
pub struct FooSpec {
#[openapi(MinLength=5)
name: String,
info: String,
#[openapi(Minimum=1, Maximum=10)]
replicas: i32,
}The thing this most reminds me of is serde attributes, but this feels a whole lot dumber than that. We just need to generate: { type: object, properties: ... } from a struct, so it's easy to attach onto the the crd json!
The problem with this is that it would necessarily conflict with serde field attributes, which are also frequently used. A dumb proc macro that wasn't aware of serde wouldn't be hard to do, but I imagine it also would cause a lot of duplication between between serde attrs like skip_serializing_if, default with validation rules.
shanesveller, innobead, lfrancke and ammarzuberi
Metadata
Metadata
Assignees
Labels
derivekube-derive proc_macro relatedkube-derive proc_macro related