1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix/gitlab project user workspace (#2881)

* Add ability to create project under a user

* Add changelog

* Change minor_changes in changelog

As suggested in this comment https://github.com/ansible-collections/community.general/pull/2824#discussion_r653411741

* Fix user's namespace

* Delete changelog

* Add changelog

* Fix changelog

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Amin Vakil <info@aminvakil.com>

* Change user_group_id to namespace_group_id

Co-authored-by: Felix Fontein <felix@fontein.de>

* Change to namespace_id

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
Stef Graces 2021-06-27 14:01:06 +02:00 committed by GitHub
parent 9dd91f949a
commit 2fb0877577
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- gitlab_project - user projects are created using namespace ID now, instead of user ID (https://github.com/ansible-collections/community.general/pull/2881).

View file

@ -345,22 +345,22 @@ def main():
gitlab_project = GitLabProject(module, gitlab_instance)
namespace = None
user_group_id = None
namespace_id = None
if group_identifier:
group = findGroup(gitlab_instance, group_identifier)
if group is None:
module.fail_json(msg="Failed to create project: group %s doesn't exists" % group_identifier)
user_group_id = group.id
namespace_id = group.id
else:
user = gitlab_instance.users.list(username=gitlab_instance.user.username)[0]
user_group_id = user.id
namespace = gitlab_instance.namespaces.list(search=gitlab_instance.user.username)[0]
namespace_id = namespace.id
if not user_group_id:
module.fail_json(msg="Failed to find the user/group id which required to find namespace")
if not namespace_id:
module.fail_json(msg="Failed to find the namespace or group ID which is required to look up the namespace")
try:
namespace = gitlab_instance.namespaces.get(user_group_id)
namespace = gitlab_instance.namespaces.get(namespace_id)
except gitlab.exceptions.GitlabGetError as e:
module.fail_json(msg="Failed to find the namespace for the given user: %s" % to_native(e))