mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix: GitLab API searches always return first found match (#3400)
* fix: return correct group id match only full_path or name * chore: add changelog fragment * fix: indentation multiple of four * refactor: use two loops * fix: typo of group id * fix: changelog fragment
This commit is contained in:
parent
43a9f09a17
commit
b6b7601615
2 changed files with 9 additions and 3 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- gitlab_group_members - ``get_group_id`` return the group ID by matching ``full_path``, ``path`` or ``name`` (https://github.com/ansible-collections/community.general/pull/3400).
|
|
@ -179,9 +179,13 @@ class GitLabGroup(object):
|
||||||
|
|
||||||
# get group id if group exists
|
# get group id if group exists
|
||||||
def get_group_id(self, gitlab_group):
|
def get_group_id(self, gitlab_group):
|
||||||
group_exists = self._gitlab.groups.list(search=gitlab_group)
|
groups = self._gitlab.groups.list(search=gitlab_group)
|
||||||
if group_exists:
|
for group in groups:
|
||||||
return group_exists[0].id
|
if group.full_path == gitlab_group:
|
||||||
|
return group.id
|
||||||
|
for group in groups:
|
||||||
|
if group.path == gitlab_group or group.name == gitlab_group:
|
||||||
|
return group.id
|
||||||
|
|
||||||
# get all members in a group
|
# get all members in a group
|
||||||
def get_members_in_a_group(self, gitlab_group_id):
|
def get_members_in_a_group(self, gitlab_group_id):
|
||||||
|
|
Loading…
Reference in a new issue