kubeplus
kubeplus copied to clipboard
CRD registration of properties with default value set to null
In odoo helm chart, there is the following section in values.yaml
updateStrategy:
type: RollingUpdate
rollingUpdate: null
When Odoo CRD is created with this helm chart, the rollingUpdate field is being ignored. The OpenAPI Spec that is registered for this CRD does not seem to contain the rollingUpdate field.
The code update for this will be in the registercrd method, specifically in the flatten method: https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L666
In the flatten method implementation (https://github.com/cloud-ark/kubeplus/blob/master/deploy/kubeconfiggenerator.py#L478),
Kubernetes supports OpenAPI Spec v3.0 (https://kubernetes.io/docs/concepts/overview/kubernetes-api/). In OpenAPI Spec 3.0, nullable values are defined using nullable property, like below:
type: string
nullable: true
See https://stackoverflow.com/questions/48111459/how-to-define-a-property-that-can-be-string-or-null-in-openapi-swagger
Given this, we need to add following code in flatten method:
if value == "null":
prop_dict = {'type': 'string', 'nullable': true}
types_dict[key] = prop_dict