-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
k8s-openapi 0.10 fails to yaml serialize crd #349
Comments
This is a problem for the new schema feature in #264 where people would definitely use this fn to apply, so ought to solve this before a new release after its merge. Will try to make a smaller example and raise against k8s-openapi. |
Minimal kube-derive example with k8s-openapi 0.10 with 1_19 feature: #[derive(kube::CustomResource, serde::Serialize, serde::Deserialize, Debug, Clone)]
#[kube(group = "clux.dev", version = "v1", kind = "Foo")]
pub struct MyFoo {
name: String,
}
fn main() {
let crd = serde_yaml::to_string(&Foo::crd()).unwrap();
println!("Foo CRD: \n{}", crd);
} trace:
|
crashing lines in k8s-openapi: impl serde::Serialize for CustomResourceDefinition {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let mut state = serializer.serialize_struct(
<Self as crate::Resource>::KIND,
4 + self.status.as_ref().map_or(0, |_| 1),
)?;
serde::ser::SerializeStruct::serialize_field(
&mut state,
"apiVersion",
<Self as crate::Resource>::API_VERSION,
)?;
serde::ser::SerializeStruct::serialize_field(
&mut state,
"kind",
<Self as crate::Resource>::KIND,
)?;
serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
serde::ser::SerializeStruct::serialize_field(&mut state, "spec", &self.spec)?;
if let Some(value) = &self.status {
serde::ser::SerializeStruct::serialize_field(&mut state, "status", value)?;
}
serde::ser::SerializeStruct::end(state)
}
} don't fully understand. HOWEVER, have reproduced this without kube-derive, so this is almost certainly a bug in k8s-openapi. Will raise an issue there. Here is a minimal example withouth use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::{CustomResourceDefinition, CustomResourceDefinitionSpec, CustomResourceDefinitionNames};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
fn main() {
let crd = CustomResourceDefinition {
metadata: ObjectMeta {
name: Some("hello".to_string()),
..ObjectMeta::default()
},
spec: CustomResourceDefinitionSpec {
group: "clux.dev".to_string(),
scope: "Cluster".to_string(),
names: CustomResourceDefinitionNames {
plural: "foos".to_string(),
kind: "Foo".to_string(),
..CustomResourceDefinitionNames::default()
},
..CustomResourceDefinitionSpec::default()
},
..CustomResourceDefinition::default()
};
let crd = serde_yaml::to_string(&crd).unwrap();
println!("Foo CRD: \n{}", crd);
} same crash |
Actually our problem using an old serde_yaml. |
This is master only, because the local version bump has not been released yet.
Reproducing
Derive a CRD, and simply primt the
serde_yaml
string. Can do this most easily by editing thecrd_derive
example to print with yaml:causes the following backtrace:
The text was updated successfully, but these errors were encountered: