Skip to content
Snippets Groups Projects
Commit 1916cdd5 authored by jurgenhaas's avatar jurgenhaas
Browse files

Improve the search for the correct project by comparing the namespace

parent 0b600fd2
No related branches found
No related tags found
No related merge requests found
......@@ -29,11 +29,13 @@ class GitLabProject(object):
if host_name:
projects = self._gitlab.projects.list(search=host_name)
if len(projects) == 1:
project = projects[0]
self.pid = project.id
self.project = project
return True
if projects:
namespace = '%s/hosts/%s' % (group_name, project_name)
for project in projects:
if project.namespace['full_path'] == namespace:
self.pid = project.id
self.project = project
return True
project = self._gitlab.projects.get('%s/%s' % (self.namespace, project_name))
if project:
......@@ -203,6 +205,7 @@ def main():
project_exists = metaProject.exists(group_name, project_name, host_name)
if not project_exists:
module.fail_json(msg="Gitlab project does not exist")
return
# Validate if user exists and get its ID
user = GitLabUser(module, git)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment