Fixed misleading helm module import failure message (#44916)

This commit is contained in:
Tristan Sweeney 2019-12-11 04:34:42 -05:00 committed by Abhijeet Kasurde
parent 19220a0607
commit 4da87fb3ee

View file

@ -104,15 +104,16 @@ EXAMPLES = '''
namespace: default
'''
import traceback
HELM_IMPORT_ERR = None
try:
import grpc
from pyhelm import tiller
from pyhelm import chartbuilder
HAS_PYHELM = True
except ImportError as exc:
HAS_PYHELM = False
except ImportError:
HELM_IMPORT_ERR = traceback.format_exc()
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
def install(module, tserver):
@ -182,9 +183,8 @@ def main():
),
supports_check_mode=True)
if not HAS_PYHELM:
module.fail_json(msg="Could not import the pyhelm python module. "
"Please install `pyhelm` package.")
if HELM_IMPORT_ERR:
module.fail_json(msg=missing_required_lib('pyhelm'), exception=HELM_IMPORT_ERR)
host = module.params['host']
port = module.params['port']