Require XR's spec field

Signed-off-by: Simon Rüegg <simon@rueggs.ch>
This commit is contained in:
Simon Rüegg 2020-12-05 16:19:36 +01:00
parent c1dec96dfb
commit 084ebffa4e
No known key found for this signature in database
GPG Key ID: FFE2AA177FBD7E17
3 changed files with 30 additions and 30 deletions

View File

@ -76,10 +76,7 @@ func ForCompositeResource(xrd *v1beta1.CompositeResourceDefinition) (*extv1.Cust
Storage: vr.Referenceable,
AdditionalPrinterColumns: append(vr.AdditionalPrinterColumns, CompositeResourcePrinterColumns()...),
Schema: &extv1.CustomResourceValidation{
OpenAPIV3Schema: &extv1.JSONSchemaProps{
Type: "object",
Properties: BaseProps(),
},
OpenAPIV3Schema: BaseProps(),
},
Subresources: &extv1.CustomResourceSubresources{
Status: &extv1.CustomResourceSubresourceStatus{},
@ -136,10 +133,7 @@ func ForCompositeResourceClaim(xrd *v1beta1.CompositeResourceDefinition) (*extv1
Storage: vr.Referenceable,
AdditionalPrinterColumns: append(vr.AdditionalPrinterColumns, CompositeResourceClaimPrinterColumns()...),
Schema: &extv1.CustomResourceValidation{
OpenAPIV3Schema: &extv1.JSONSchemaProps{
Type: "object",
Properties: BaseProps(),
},
OpenAPIV3Schema: BaseProps(),
},
Subresources: &extv1.CustomResourceSubresources{
Status: &extv1.CustomResourceSubresourceStatus{},

View File

@ -153,7 +153,8 @@ func TestForCompositeResource(t *testing.T) {
},
Schema: &extv1.CustomResourceValidation{
OpenAPIV3Schema: &extv1.JSONSchemaProps{
Type: "object",
Type: "object",
Required: []string{"spec"},
Properties: map[string]extv1.JSONSchemaProps{
"apiVersion": {
Type: "string",
@ -477,7 +478,8 @@ func TestForCompositeResourceClaim(t *testing.T) {
},
Schema: &extv1.CustomResourceValidation{
OpenAPIV3Schema: &extv1.JSONSchemaProps{
Type: "object",
Type: "object",
Required: []string{"spec"},
Properties: map[string]extv1.JSONSchemaProps{
"apiVersion": {
Type: "string",

View File

@ -33,26 +33,30 @@ var FilterClaimSpecProps = []string{"resourceRef", "writeConnectionSecretToRef"}
// BaseProps is a partial OpenAPIV3Schema for the spec fields that Crossplane
// expects to be present for all CRDs that it creates.
func BaseProps() map[string]extv1.JSONSchemaProps {
return map[string]extv1.JSONSchemaProps{
"apiVersion": {
Type: "string",
},
"kind": {
Type: "string",
},
"metadata": {
// NOTE(muvaf): api-server takes care of validating
// metadata.
Type: "object",
},
"spec": {
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{},
},
"status": {
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{},
func BaseProps() *extv1.JSONSchemaProps {
return &extv1.JSONSchemaProps{
Type: "object",
Required: []string{"spec"},
Properties: map[string]extv1.JSONSchemaProps{
"apiVersion": {
Type: "string",
},
"kind": {
Type: "string",
},
"metadata": {
// NOTE(muvaf): api-server takes care of validating
// metadata.
Type: "object",
},
"spec": {
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{},
},
"status": {
Type: "object",
Properties: map[string]extv1.JSONSchemaProps{},
},
},
}
}