CRD Schema Fixes for CRD v1
Updated crds for require schema elements.
Additional updates to v1 will follow in another PR.
@@ -93,7 +93,7 @@ func generateOperator() *apiextv1beta1.CustomResourceDefinition {
"description": apiextv1beta1.JSONSchemaProps{Type: "string"},
"kubernetesVersion": apiextv1beta1.JSONSchemaProps{Type: "string"},
"kudoVersion": apiextv1beta1.JSONSchemaProps{Type: "string"},
- "maintainers": apiextv1beta1.JSONSchemaProps{
+ "maintainers": apiextv1beta1.JSONSchemaProps{Type: "object",
Items: &apiextv1beta1.JSONSchemaPropsOrArray{Schema: &apiextv1beta1.JSONSchemaProps{
Type: "object",
Properties: maintainers,
@@ -109,9 +109,8 @@ func generateOperator() *apiextv1beta1.CustomResourceDefinition {
"spec": apiextv1beta1.JSONSchemaProps{Properties: specProps, Type: "object"},
"status": apiextv1beta1.JSONSchemaProps{Type: "object"},
}
-
crd.Spec.Validation = &apiextv1beta1.CustomResourceValidation{
- OpenAPIV3Schema: &apiextv1beta1.JSONSchemaProps{
+ OpenAPIV3Schema: &apiextv1beta1.JSONSchemaProps{Type: "object",
Properties: validationProps,
},
}
@@ -180,7 +179,7 @@ func generateOperatorVersion() *apiextv1beta1.CustomResourceDefinition {
}
crd.Spec.Validation = &apiextv1beta1.CustomResourceValidation{
- OpenAPIV3Schema: &apiextv1beta1.JSONSchemaProps{
+ OpenAPIV3Schema: &apiextv1beta1.JSONSchemaProps{Type: "object",
Properties: validationProps,
},
}
@@ -233,7 +232,7 @@ func generateInstance() *apiextv1beta1.CustomResourceDefinition {
}
crd.Spec.Validation = &apiextv1beta1.CustomResourceValidation{
- OpenAPIV3Schema: &apiextv1beta1.JSONSchemaProps{
+ OpenAPIV3Schema: &apiextv1beta1.JSONSchemaProps{Type: "object",
Properties: validationProps,
},
}
@@ -267,6 +266,10 @@ func generateCrd(kind string, plural string) *apiextv1beta1.CustomResourceDefini
StoredVersions: []string{},
},
}
+ // below is needed if we support 1.15 CRD in v1beta1, it is deprecated within the 1.15
+ // for 1.16 it is removed and functions as if preserve == false
+ // preserveFields := false
+ // crd.Spec.PreserveUnknownFields = &preserveFields
return crd
}
