mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* 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>
(cherry picked from commit 2fb0877577
)
Co-authored-by: Stef Graces <stef.graces@nubera.eu>
This commit is contained in:
parent
ef8aa73dab
commit
d32193afef
2 changed files with 10 additions and 7 deletions
|
@ -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).
|
|
@ -345,22 +345,22 @@ def main():
|
||||||
gitlab_project = GitLabProject(module, gitlab_instance)
|
gitlab_project = GitLabProject(module, gitlab_instance)
|
||||||
|
|
||||||
namespace = None
|
namespace = None
|
||||||
user_group_id = None
|
namespace_id = None
|
||||||
if group_identifier:
|
if group_identifier:
|
||||||
group = findGroup(gitlab_instance, group_identifier)
|
group = findGroup(gitlab_instance, group_identifier)
|
||||||
if group is None:
|
if group is None:
|
||||||
module.fail_json(msg="Failed to create project: group %s doesn't exists" % group_identifier)
|
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:
|
else:
|
||||||
user = gitlab_instance.users.list(username=gitlab_instance.user.username)[0]
|
namespace = gitlab_instance.namespaces.list(search=gitlab_instance.user.username)[0]
|
||||||
user_group_id = user.id
|
namespace_id = namespace.id
|
||||||
|
|
||||||
if not user_group_id:
|
if not namespace_id:
|
||||||
module.fail_json(msg="Failed to find the user/group id which required to find namespace")
|
module.fail_json(msg="Failed to find the namespace or group ID which is required to look up the namespace")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
namespace = gitlab_instance.namespaces.get(user_group_id)
|
namespace = gitlab_instance.namespaces.get(namespace_id)
|
||||||
except gitlab.exceptions.GitlabGetError as e:
|
except gitlab.exceptions.GitlabGetError as e:
|
||||||
module.fail_json(msg="Failed to find the namespace for the given user: %s" % to_native(e))
|
module.fail_json(msg="Failed to find the namespace for the given user: %s" % to_native(e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue