Skip to content

Commit

Permalink
Merge pull request #80 from kubevirt-bot/cherry-pick-79-to-release-v0.5
Browse files Browse the repository at this point in the history
[release-v0.5] Fixed CRD definition in helper, so csv-generator has proper CRD
  • Loading branch information
awels authored Jul 27, 2020
2 parents bb7f7ec + 01fd3a1 commit 1f5a4bd
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 9 deletions.
56 changes: 47 additions & 9 deletions tools/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func CreateCRDDef() *extv1.CustomResourceDefinition {
Schema: &extv1.CustomResourceValidation{
OpenAPIV3Schema: &extv1.JSONSchemaProps{
Type: "object",
Description: "Represents a HostPathProvisioner deployment",
Description: "HostPathProvisioner is the Schema for the hostpathprovisioners API",
Properties: map[string]extv1.JSONSchemaProps{
"apiVersion": {
Type: "string",
Expand All @@ -173,7 +173,8 @@ func CreateCRDDef() *extv1.CustomResourceDefinition {
Type: "string",
},
"imagePullPolicy": {
Type: "string",
Description: "PullPolicy describes a policy for if/when to pull a container image",
Type: "string",
Enum: []extv1.JSON{
{
Raw: []byte(`"Always"`),
Expand All @@ -187,42 +188,79 @@ func CreateCRDDef() *extv1.CustomResourceDefinition {
},
},
"pathConfig": {
Description: "describes the location and layout of PV storage on nodes",
Description: "PathConfig describes the location and layout of PV storage on nodes",
Properties: map[string]extv1.JSONSchemaProps{
"path": {
Description: "The provisioner will store PVs at this location on each node",
Description: "Path The path the directories for the PVs are created under",
Type: "string",
},
"useNamingPrefix": {
Description: "Indicates whether the name of the requesting PVC is included in the directory name when dynamically provisioning a PV",
Description: "UseNamingPrefix Use the name of the PVC requesting the PV as part of the directory created",
Type: "boolean",
},
},
Type: "object",
},
},
Type: "object",
Required: []string{
"pathConfig",
},
},
"status": {
Description: "HostPathProvisionerStatus defines the observed state of HostPathProvisioner",
Properties: map[string]extv1.JSONSchemaProps{
"conditions": {
Description: "Conditions contains the current conditions observed by the operator",
Type: "array",
Items: &extv1.JSONSchemaPropsOrArray{
Schema: &extv1.JSONSchemaProps{
Description: "Condition represents the state of the operator's reconciliation functionality.",
Properties: map[string]extv1.JSONSchemaProps{
"lastHeartbeatTime": {
Format: "date-time",
Type: "string",
},
"lastTransitionTime": {
Format: "date-time",
Type: "string",
},
"message": {
Type: "string",
},
"reason": {
Type: "string",
},
"status": {
Type: "string",
},
"type": {
Description: "ConditionType is the state of the operator's reconciliation functionality.",
Type: "string",
},
},
Required: []string{
"status",
"type",
},
Type: "object",
},
},
Type: "array",
},
"observedVersion": {
Description: "The observed version of the HostPathProvisioner deployment",
Description: "ObservedVersion The observed version of the HostPathProvisioner deployment",
Type: "string",
},
"operatorVersion": {
Description: "The version of the HostPathProvisioner Operator",
Description: "OperatorVersion The version of the HostPathProvisioner Operator",
Type: "string",
},
"targetVersion": {
Description: "The targeted version of the HostPathProvisioner deployment",
Description: "TargetVersion The targeted version of the HostPathProvisioner deployment",
Type: "string",
},
},
Type: "object",
},
},
},
Expand Down
50 changes: 50 additions & 0 deletions tools/yaml-dumper/yaml-dumper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

package main

import (
"flag"
"os"
"path/filepath"

extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"kubevirt.io/hostpath-provisioner-operator/tools/helper"
"kubevirt.io/hostpath-provisioner-operator/tools/util"
)

var (
exportPath = flag.String("export-path", "", "")
)

// Export the CDI CRDs schemas from code to yaml.
func main() {
flag.Parse()

if *exportPath != "" {
if err := os.Mkdir(*exportPath, 0755); !os.IsExist(err) {
panic(err)
}
}
crds := make([]*extv1.CustomResourceDefinition, 0)
crds = append(crds, helper.CreateCRDDef())

for _, crd := range crds {
crdPath := filepath.Join(*exportPath, crd.GetObjectMeta().GetName())
crdSchemaFile, err := os.Create(crdPath)
if err != nil {
panic(err)
}
crd.Spec.Conversion = nil
util.MarshallObject(crd, crdSchemaFile)
}
}

0 comments on commit 1f5a4bd

Please sign in to comment.