You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
apiVersion: apiextensions.k8s.io/v1kind: CustomResourceDefinitionmetadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0creationTimestamp: nullname: transforminputs.app.yndd.iospec:
group: app.example.ionames:
categories:
- appkind: TransformInputlistKind: TransformInputListplural: transforminputssingular: transforminputscope: Namespacedversions:
- name: v1alpha1schema:
openAPIV3Schema:
description: TransformInput is the Schema for the TransformInput APIproperties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'type: stringkind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'type: stringmetadata:
type: objectspec:
description: TransformInputSpec structproperties:
origin:
type: objecttarget:
type: objecttype: objecttype: objectserved: truestorage: true
when I use kopium to generate the rust code I get this.
use kube::CustomResource;use schemars::JsonSchema;use serde::{Serialize,Deserialize};/// TransformInputSpec struct#[derive(CustomResource,Serialize,Deserialize,Clone,Debug,JsonSchema)]#[kube( group = "app.example.io", version = "v1alpha1", kind = "TransformInput", plural = "transforminputs")]#[kube(namespaced)]pubstructTransformInputSpec{#[serde(default, skip_serializing_if = "Option::is_none")]puborigin:Option<TransformInputOrigin>,#[serde(default, skip_serializing_if = "Option::is_none")]pubtarget:Option<TransformInputTarget>,}#[derive(Serialize,Deserialize,Clone,Debug,JsonSchema)]pubstructTransformInputOrigin{}#[derive(Serialize,Deserialize,Clone,Debug,JsonSchema)]pubstructTransformInputTarget{}
As you can see the struct TransformInputOrigin and TransformInputTarget are empty. The issue is that when you serializer/deserializerl it in json/yaml the data behind these object is no longer accessible.
When I change it to the following manually the marshal/unmarshal function works as the serde_json::Value is seen as a generic object in the serializer/deserializer afaik.
use kube::CustomResource;use schemars::JsonSchema;use serde::{Deserialize,Serialize};use serde_json::Value;/// TransformInputSpec struct#[derive(CustomResource,Serialize,Deserialize,Clone,Debug,JsonSchema)]#[kube( group = "app.example.io", version = "v1alpha1", kind = "TransformInput", plural = "transforminputs")]#[kube(namespaced)]pubstructTransformInputSpec{#[serde(default, skip_serializing_if = "Option::is_none")]puborigin:Option<Value>,#[serde(default, skip_serializing_if = "Option::is_none")]pubtarget:Option<Value>,}
Can this be accommodated?
The text was updated successfully, but these errors were encountered:
Hm, crd specification wise, I feel like the schema should really generate those objects (origin and target) with a x-preserve-unknown-fields specifier (see #31) so that we know that it's worth deserialising the properties into a serde_json::Value, because otherwise, I think what we are doing is technically correct.
However, it's possible we could have a flag for making empty-struct always use Value rather than empty structs. Need to consider this when implementing #31.
Thanks for the report, will try to dig into this when I have time.
runtime.RawExtensions serves as a blob in the k8s CRD afaik and is reflected as an object in the openapi spec, like this.
The specific objects are origin and target, which are defined in go as following
when I use kopium to generate the rust code I get this.
As you can see the struct TransformInputOrigin and TransformInputTarget are empty. The issue is that when you serializer/deserializerl it in json/yaml the data behind these object is no longer accessible.
When I change it to the following manually the marshal/unmarshal function works as the serde_json::Value is seen as a generic object in the serializer/deserializer afaik.
Can this be accommodated?
The text was updated successfully, but these errors were encountered: