strip description from CRD validation properties
@@ -24,9 +24,11 @@ import (
"fmt"
crdutils "github.com/ant31/crd-validation/pkg"
+ "github.com/go-openapi/spec"
extensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ common "k8s.io/kube-openapi/pkg/common"
"kubevirt.io/kubevirt/pkg/api/v1"
)
@@ -60,12 +62,32 @@ func generateVirtualMachineCrd() {
Kind: v1.VirtualMachineGroupVersionKind.Kind,
ShortNames: []string{"vm", "vms"},
},
- Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachine", v1.GetOpenAPIDefinitions),
+ Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachine", definitionWrapper),
}
crdutils.MarshallCrd(crd, "yaml")
}
+func stripDescription(schema spec.Schema) spec.Schema {
+ schema.SchemaProps.Description = ""
+
+ for key, val := range schema.SchemaProps.Properties {
+ schema.SchemaProps.Properties[key] = stripDescription(val)
+ }
+ return schema
+}
+
+func definitionWrapper(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
+ definitions := v1.GetOpenAPIDefinitions(ref)
+
+ for key, val := range definitions {
+ val.Schema = stripDescription(val.Schema)
+ definitions[key] = val
+ }
+
+ return definitions
+}
+
func generatePresetCrd() {
crd := generateBlankCrd()
@@ -81,7 +103,7 @@ func generatePresetCrd() {
Kind: v1.VirtualMachineInstancePresetGroupVersionKind.Kind,
ShortNames: []string{"vmipreset", "vmipresets"},
},
- Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachineInstancePreset", v1.GetOpenAPIDefinitions),
+ Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachineInstancePreset", definitionWrapper),
}
crdutils.MarshallCrd(crd, "yaml")
@@ -102,7 +124,7 @@ func generateReplicaSetCrd() {
Kind: v1.VirtualMachineInstanceReplicaSetGroupVersionKind.Kind,
ShortNames: []string{"vmirs", "vmirss"},
},
- Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachineInstanceReplicaSet", v1.GetOpenAPIDefinitions),
+ Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachineInstanceReplicaSet", definitionWrapper),
}
crdutils.MarshallCrd(crd, "yaml")
@@ -123,7 +145,7 @@ func generateVirtualMachineInstanceCrd() {
Kind: v1.VirtualMachineInstanceGroupVersionKind.Kind,
ShortNames: []string{"vmi", "vmis"},
},
- Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachineInstance", v1.GetOpenAPIDefinitions),
+ Validation: crdutils.GetCustomResourceValidation("kubevirt.io/kubevirt/pkg/api/v1.VirtualMachineInstance", definitionWrapper),
}
crdutils.MarshallCrd(crd, "yaml")
