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
#[serde(tag="tag")]
pub enum TaggedUnion {
Left {
left_value: String
},
Right {
right_value: String
}
}
Calling TestObject::crd() causes an error like:
Property "tag" has the schema ... enum_values: Some([String("Right")]) ... but was already defined as ... enum_values: Some([String("Left")]) ... in another subschema. The schemas for a property used in multiple subschemas must be identical'...
The whole error message:
thread 'main' panicked at 'Property "tag" has the schema Object(SchemaObject { metadata: None, instance_type: Some(Single(String)), format: None, enum_values: Some([String("Right")]), const_value: None, subschemas: None, number: None, string: None, array: None, object: None, reference: None, extensions: {} }) but was already defined as Object(SchemaObject { metadata: None, instance_type: Some(Single(String)), format: None, enum_values: Some([String("Left")]), const_value: None, subschemas: None, number: None, string: None, array: None, object: None, reference: None, extensions: {} }) in another subschema. The schemas for a property used in multiple subschemas must be identical'...
for each field in an object and each item in an array which is specified within any of allOf, anyOf, oneOf or not, the schema also specifies the field/item outside of those logical junctors (compare example 1 and 2).
If I understood it correctly, then internally tagged representation of rust enums in k8s crds is not possible.
Yeah, unfortunately this is an expected failure. We have some enum requirements in the docs for the CustomResource derive. If you know what you are doing you might be able to override certain problematic parts of the schema - but do not know how practical that is for most people / most use-cases.
Current and expected behavior
A structure below has Internally tagged enum representation (which is enabled by
#[serde(tag="tag")]
)).Calling
TestObject::crd()
causes an error like:The whole error message:
The test case is here https://github.com/kevroletin/kube.rs-tagged-union-test
Possible solution
No response
Additional context
This is an example of Internally tagged representation:
This is an example of Externally tagged representation. This is default and generating crd for that representations works:
It seems that the problem is related to Schema postprocesing done by kube.rs
Environment
Client Version: v1.24.3
Kustomize Version: v4.5.4
Server Version: v1.23.17-eks-2d98532
Configuration and features
Affected crates
kube-derive
Would you like to work on fixing this bug?
None
The text was updated successfully, but these errors were encountered: