Commit 1916cdd5 authored by Jürgen Haas's avatar Jürgen Haas

Improve the search for the correct project by comparing the namespace

parent 0b600fd2
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment