Skip to content

Commit

Permalink
Handle VersionNotSupportedErrors not being supported
Browse files Browse the repository at this point in the history
Need to ensure that validate still works with older kubernetes_validate
  • Loading branch information
willthames authored and fabianvf committed Feb 3, 2019
1 parent 7444366 commit 66c8670
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openshift/dynamic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
except ImportError:
HAS_KUBERNETES_VALIDATE = False

try:
from kubernetes_validate.utils import VersionNotSupportedError
except ImportError:
class VersionNotSupportedError(NotImplementedError):
pass

__all__ = [
'DynamicClient',
Expand Down Expand Up @@ -292,7 +297,7 @@ def validate(self, definition, version=None, strict=False):
kubernetes_validate.validate(definition, version, strict)
except kubernetes_validate.utils.ValidationError as e:
errors.append("resource definition validation error at %s: %s" % ('.'.join([str(item) for item in e.path]), e.message)) # noqa: B306
except kubernetes_validate.utils.VersionNotSupportedError as e:
except VersionNotSupportedError as e:
errors.append("Kubernetes version %s is not supported by kubernetes-validate" % version)
except kubernetes_validate.utils.SchemaNotFoundError as e:
warnings.append("Could not find schema for object kind %s with API version %s in Kubernetes version %s (possibly Custom Resource?)" %
Expand Down

0 comments on commit 66c8670

Please sign in to comment.