mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
gitlab_project_members: improve project name matching (#3602)
* Update gitlab_project_members.py The actual search method doesn't accept path with namespace for project_name. If you have many project with same name, this module gitlab_project_members can't work. * Update gitlab_project_members.py * Update gitlab_project_members.py * Update gitlab_project_members.py * Create 3602-fix-gitlab_project_members-improve-search-method * Rename 3602-fix-gitlab_project_members-improve-search-method to 3602-fix-gitlab_project_members-improve-search-method.yml
This commit is contained in:
parent
9fb76efde0
commit
cdfc4dcf49
2 changed files with 10 additions and 4 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- gitlab_project_members - ``get_project_id`` return the project id by matching ``full_path`` or ``name`` (https://github.com/ansible-collections/community.general/pull/3602).
|
|
@ -48,7 +48,7 @@ options:
|
|||
type: str
|
||||
project:
|
||||
description:
|
||||
- The name of the GitLab project the member is added to/removed from.
|
||||
- The name (or full path) of the GitLab project the member is added to/removed from.
|
||||
required: true
|
||||
type: str
|
||||
gitlab_user:
|
||||
|
@ -194,6 +194,10 @@ class GitLabProjectMembers(object):
|
|||
self._gitlab = gl
|
||||
|
||||
def get_project(self, project_name):
|
||||
try:
|
||||
project_exists = self._gitlab.projects.get(project_name)
|
||||
return project_exists.id
|
||||
except gitlab.exceptions.GitlabGetError as e:
|
||||
project_exists = self._gitlab.projects.list(search=project_name)
|
||||
if project_exists:
|
||||
return project_exists[0].id
|
||||
|
|
Loading…
Reference in a new issue