-
Notifications
You must be signed in to change notification settings - Fork 247
/
cdiconfig.go
34 lines (27 loc) · 990 Bytes
/
cdiconfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package cluster
import (
"strings"
extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
"kubevirt.io/containerized-data-importer/pkg/operator/resources"
)
// NewCdiConfigCrd - provides CDIConfig CRD
func NewCdiConfigCrd() *extv1.CustomResourceDefinition {
return createCDIConfigCRD()
}
// createCDIConfigCRD creates the CDIConfig schema
func createCDIConfigCRD() *extv1.CustomResourceDefinition {
crd := extv1.CustomResourceDefinition{}
_ = k8syaml.NewYAMLToJSONDecoder(strings.NewReader(resources.CDICRDs["cdiconfig"])).Decode(&crd)
return &crd
}
// CreateConfigPropertiesSchema creates the CDIConfigSpec properties schema
func CreateConfigPropertiesSchema() map[string]extv1.JSONSchemaProps {
crd := createCDIConfigCRD()
for _, version := range crd.Spec.Versions {
if version.Storage {
return version.Schema.OpenAPIV3Schema.Properties["spec"].Properties
}
}
return make(map[string]extv1.JSONSchemaProps)
}