Skip to content

Commit

Permalink
Merge pull request #334 from dinhxuanvu/fix-unstructured
Browse files Browse the repository at this point in the history
Bug 1838756: fix(validation): Fix CRD v1beta int-float conversion error
  • Loading branch information
openshift-merge-robot committed May 26, 2020
2 parents 18b8ef3 + 537caf5 commit 04e4e88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ spec:
singular: etcdcluster
scope: Namespaced
version: v1beta2
validation:
openAPIV3Schema:
properties:
spec:
type: object
properties:
test:
type: integer
minimum: 1
maximum: 32767
5 changes: 3 additions & 2 deletions pkg/lib/bundle/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,11 @@ func (i imageValidator) ValidateBundleContent(manifestDir string) error {
}
}
} else if gvk.Kind == CRDKind {
dec := k8syaml.NewYAMLOrJSONDecoder(strings.NewReader(string(data)), 30)
switch gv := gvk.GroupVersion().String(); gv {
case v1CRDapiVersion:
crd := &apiextensionsv1.CustomResourceDefinition{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(k8sFile.Object, crd)
err := dec.Decode(crd)
if err != nil {
validationErrors = append(validationErrors, err)
continue
Expand All @@ -330,7 +331,7 @@ func (i imageValidator) ValidateBundleContent(manifestDir string) error {
}
case v1beta1CRDapiVersion:
crd := &apiextensionsv1beta1.CustomResourceDefinition{}
err := runtime.DefaultUnstructuredConverter.FromUnstructured(k8sFile.Object, crd)
err := dec.Decode(crd)
if err != nil {
validationErrors = append(validationErrors, err)
continue
Expand Down

0 comments on commit 04e4e88

Please sign in to comment.