validate: check the version of python-notario

If the version of python-notario is < 0.0.13 an error message is given
like "TypeError: validate() got an unexpected keyword argument
'defined_keys'", which is not helpful in figuring
out you've got an incorrect version of python-notario.

This check will avoid that situation by telling the user that they need
to upgrade python-notario before they hit that error.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
pull/2992/head
Andrew Schoen 2018-10-16 10:20:54 -05:00 committed by mergify[bot]
parent 8fa437b7bd
commit a439eb574d
1 changed files with 6 additions and 0 deletions

View File

@ -1,5 +1,6 @@
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase
from distutils.version import LooseVersion
try: try:
from __main__ import display from __main__ import display
@ -14,6 +15,11 @@ except ImportError:
display.error(msg) display.error(msg)
raise SystemExit(msg) raise SystemExit(msg)
if LooseVersion(notario.__version__) < LooseVersion("0.0.13"):
msg = "The python-notario libary has an incompatible version. Version >= 0.0.13 is needed, current version: %s" % notario.__version__
display.error(msg)
raise SystemExit(msg)
from notario.exceptions import Invalid from notario.exceptions import Invalid
from notario.validators import types, chainable, iterables from notario.validators import types, chainable, iterables
from notario.decorators import optional from notario.decorators import optional