mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 15:34:01 -07:00
gitlab modules: improved imports (#5259)
* gitlab modules: improved imports * add changelog fragment * refactored the import check to its sole function
This commit is contained in:
parent
5470ea30dc
commit
6b463e6fa6
14 changed files with 85 additions and 170 deletions
|
@ -155,19 +155,11 @@ EXAMPLES = r'''
|
|||
RETURN = r''' # '''
|
||||
|
||||
from ansible.module_utils.api import basic_auth_argument_spec
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.gitlab import auth_argument_spec, gitlab_authentication
|
||||
|
||||
import traceback
|
||||
|
||||
try:
|
||||
import gitlab
|
||||
HAS_PY_GITLAB = True
|
||||
GITLAB_IMP_ERR = None
|
||||
except ImportError:
|
||||
GITLAB_IMP_ERR = traceback.format_exc()
|
||||
HAS_PY_GITLAB = False
|
||||
from ansible_collections.community.general.plugins.module_utils.gitlab import (
|
||||
auth_argument_spec, gitlab_authentication, gitlab, ensure_gitlab_package
|
||||
)
|
||||
|
||||
|
||||
class GitLabProjectMembers(object):
|
||||
|
@ -282,9 +274,7 @@ def main():
|
|||
],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
if not HAS_PY_GITLAB:
|
||||
module.fail_json(msg=missing_required_lib('python-gitlab', url='https://python-gitlab.readthedocs.io/en/stable/'), exception=GITLAB_IMP_ERR)
|
||||
ensure_gitlab_package(module)
|
||||
|
||||
access_level_int = {
|
||||
'guest': gitlab.GUEST_ACCESS,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue