-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gitlab_project_members: Added group sharing and unsharing logic for issue #8658 #8676
base: main
Are you sure you want to change the base?
Conversation
@Acarnesecchi this PR contains the following merge commits: Please rebase your branch to remove these commits. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
2b973da
to
175a8fc
Compare
@felixfontein I am trying to reach out to someone on libera.chat IRC but apparently I am not allowed to send messages in #ansible-devel channel. What can I do? |
@Acarnesecchi please ignore the IRC part of the bot's message, you don't need to ask any core team member there (this is a collection, not ansible-core; and also the problem here isn't that a core review is needed). The main problem here is that your commit contains a lot of changes that don't belong to this PR and shouldn't be in there. If you check out the Files tab of this PR you can see what I mean: https://github.com/ansible-collections/community.general/pull/8676/files |
@felixfontein my fork is clean now, please, let me know if anything else is needed. Thx! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Can you please add a changelog fragment? Thanks.
type: list | ||
elements: dict | ||
suboptions: | ||
name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use two different fields for ID and name, instead of having to figure out whether a string is an ID or a name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the other modules that use the group variable work with both ID and name. I would leave it as it is for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether it's this way in the other modules for backwards compatibility, or because it is the best solution. I hope that some of the GitLab module maintainers can weight in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif module.params['gitlab_group'] is not None: | ||
gitlab_groups = module.params['gitlab_group'] | ||
groups = project.get_groups_in_a_project(gitlab_project_id) | ||
if groups: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition looks wrong to me. If module.params['gitlab_group'] is not None
but groups
happens to be empty, the below cases are handled, and eventually the module exits with "Nothing to do, please give at least one user or group or set purge_users true.". That doesn't sound right to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem is still there. Just because the module argument is not None
doesn't mean the list is not empty.
changed_data = [] | ||
|
||
for gitlab_user in gitlab_users_access: | ||
gitlab_user_id = project.get_user_id(gitlab_user['name']) | ||
if members: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition also looks suspicious.
0d429ae
to
79cc6d7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @Acarnesecchi thanks for your contribution!
I got a couple of comments there, nothing major.
for gid in groups: | ||
if gid == group_id: | ||
return True | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More pythonic as:
for gid in groups: | |
if gid == group_id: | |
return True | |
return False | |
return any(group_id == gid for gid in groups) |
options=dict( | ||
name=dict(type='str', required=True), | ||
group_access_level=dict(type='str', choices=[ | ||
'guest', 'reporter', 'developer', 'maintainer'], required=False), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant
'guest', 'reporter', 'developer', 'maintainer'], required=False), | |
'guest', 'reporter', 'developer', 'maintainer']), |
SUMMARY
Modifies the ansible_project_members module to add the possibility to share and unshare projects with one or more groups. This is supported both by the API and the python-gitlab library.
Fix #8658
ISSUE TYPE
gitlab_project_members.py
ADDITIONAL INFORMATION