1
0
Fork 0
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) (#3635)

* 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

(cherry picked from commit cdfc4dcf49)

Co-authored-by: paytroff <93038288+paytroff@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-10-30 08:31:53 +02:00 committed by GitHub
parent f4d16549de
commit 9e19286a9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -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).

View file

@ -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:
@ -118,9 +118,13 @@ class GitLabProjectMembers(object):
self._gitlab = gl
def get_project(self, project_name):
project_exists = self._gitlab.projects.list(search=project_name)
if project_exists:
return project_exists[0].id
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
def get_user_id(self, gitlab_user):
user_exists = self._gitlab.users.list(username=gitlab_user)