Closed
Description
Here is a valid CRD spec:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: widgets.test.com
spec:
group: test.com
names:
kind: Widget
listKind: WidgetList
plural: widgets
singular: widget
scope: Namespaced
version: v1
versions:
- name: v1
served: true
storage: true
preserveUnknownFields: false
subresources:
status: {}
validation:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
edges:
type: integer
hollow:
type: boolean
default: false
dimensions:
type: object
properties:
x:
type: integer
y:
type: integer
zoom:
type: boolean
default: false
edgeTemplates:
type: array
items:
type: object
properties:
spiky:
type: boolean
default: true
This is accepted by kubernetes server version 1.15.10. However, this is unparseable via fabric8 CustomResourceDefinition.class:
String yaml = "insert above";
Serialization.unmarshal(yaml, CustomResourceDefinition.class);
This fails with the following MismatchedInputException:
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `io.fabric8.kubernetes.api.model.apiextensions.JSON` (although at least one Creator exists): no boolean/Boolean-argument constructor/factory method to deserialize from boolean value (false)
at [Source: (BufferedInputStream); line: 32, column: 24] (through reference chain: io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition["spec"]->io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionSpec["validation"]->io.fabric8.kubernetes.api.model.apiextensions.CustomResourceValidation["openAPIV3Schema"]->io.fabric8.kubernetes.api.model.apiextensions.JSONSchemaProps["properties"]->java.util.LinkedHashMap["spec"]->io.fabric8.kubernetes.api.model.apiextensions.JSONSchemaProps["properties"]->java.util.LinkedHashMap["hollow"]->io.fabric8.kubernetes.api.model.apiextensions.JSONSchemaProps["default"])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1343)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1032)
at com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromBoolean(ValueInstantiator.java:280)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromBoolean(StdValueInstantiator.java:393)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromBoolean(BeanDeserializerBase.java:1426)
If you remove the default: false
from hollow
and zoom
, it works. It seems like the default: true
in spiky
does work. Note: the true/false values don't matter. It appears that the parsing works within nested arrays of objects, but not nested objects. Not sure why that is.
Metadata
Metadata
Assignees
Labels
No labels