diff --git a/operatorcourier/validate.py b/operatorcourier/validate.py index 2a4a4fa..044fdf9 100644 --- a/operatorcourier/validate.py +++ b/operatorcourier/validate.py @@ -160,6 +160,20 @@ def _crd_validation(self, bundle): if "version" not in crd['spec']: self._log_error("crd spec.version or spec.versions not defined") valid = False + if "versions" in crd['spec']: + if "version" in crd['spec']: + if "name" in crd['spec']['versions'][0]: + if crd['spec']['version'] != \ + crd['spec']['versions'][0]['name']: + self._log_error("crd spec.version must be " + "the first element in crd spec.versions") + valid = False + else: + if crd['spec']['version'] != \ + crd['spec']['versions'][0]: + self._log_error("crd spec.version must be " + "the first element in crd spec.versions") + valid = False return valid diff --git a/tests/test_files/bundles/verification/crdversions.invalid.bundle.yaml b/tests/test_files/bundles/verification/crdversions.invalid.bundle.yaml index 1512e96..9960149 100644 --- a/tests/test_files/bundles/verification/crdversions.invalid.bundle.yaml +++ b/tests/test_files/bundles/verification/crdversions.invalid.bundle.yaml @@ -340,6 +340,9 @@ data: - registryNamespace type: object version: v1alpha1 + versions: + - v1beta1 + - v1alpha1 packages: | - channels: - currentCSV: marketplace-operator.v0.0.1 diff --git a/tests/test_files/bundles/verification/crdversions.valid.bundle.yaml b/tests/test_files/bundles/verification/crdversions.valid.bundle.yaml index 92f4c7a..72c6624 100644 --- a/tests/test_files/bundles/verification/crdversions.valid.bundle.yaml +++ b/tests/test_files/bundles/verification/crdversions.valid.bundle.yaml @@ -341,6 +341,9 @@ data: - registryNamespace type: object version: v1alpha1 + versions: + - v1alpha1 + - v1beta1 packages: | - channels: - currentCSV: marketplace-operator.v0.0.1