-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
make schema a default compile feature of kube-derive - for #355 #356
Conversation
for people wishing to minise their dependencies, add a skip_crd kube attr.
cc @kazk in case you are working on more :-) |
Note that I feel that it be more ideal if we did this based on whether or not the type already derives |
Looks good to me 👍 This will be nice for those who want to minimize dependency like you wrote. For those that already have schema written manually with validation rules and want to update with minimal change, they should be able to do the following (example from #264 (comment)): impl JsonSchema for H2OSpec {
// ...
fn json_schema(_: &mut SchemaGenerator) -> Schema {
serde_yaml::from_str(H2O_SPEC_SCHEMA).unwrap()
}
}
const H2O_SPEC_SCHEMA: &str = r#"
# just the value of openAPIV3Schema
"#;
Yeah, I couldn't find it either when I looked into making |
hmmm, that is also a good solution. Possibly even better than this. The manual hijack of h2o you mentioned is definitely usable, but leaves a little to be desired on our end. A couple of CONs:
The only way to allow manual specification with some safety, and at the same time not have the The benefit of all this, I guess, would be that they would have at least Whether or not it's worth it, is another question. But it's at least easy to compile-time disable schemars generation, and put in a warning for users that they are in manual mode. |
Yeah, I'd vote for |
allows manually implementing it OR manually constructing a schema from json/yaml. example included.
merry fucking xmas. and in particular, merry xmas to @shanesveller thank you, and enjoy your dubious sponsor benefit :D
turns out that you can't easily exclude one test with non-default-features thus, we make it a noop for the first run, then run it manually later
It's now a feature. The hairiest part by far was making the examples + CI able to switch between the various versions of it, but the dedicated example for it should be easy to follow at the very least. |
While the issue was closed, and the solution we have seems pretty solid, I can also see a case for people wishing to minimise their dependency trees a bit.This adds a#[kube(skip_crd)]
bool tokube-derive
which casesFoo::crd
to not be implemented.Because of how good thecrd
generation now is, it's opt-out, rather than opt-in.