Skip to content
Snippets Groups Projects
Commit cd449dbd authored by ale's avatar ale
Browse files

Catch 404 errors when accessing non-existing projects

parent 5d594ae0
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,11 @@ _from_rx = re.compile(r'^FROM\s+(\S+).*$', re.MULTILINE) ...@@ -51,7 +51,11 @@ _from_rx = re.compile(r'^FROM\s+(\S+).*$', re.MULTILINE)
def get_docker_deps(gl, project_path, branch_name): def get_docker_deps(gl, project_path, branch_name):
try:
p = gl.projects.get(project_path) p = gl.projects.get(project_path)
except Exception as e:
logging.error('error accessing project %s: %s', project_path, e)
return []
try: try:
f = p.files.get(file_path='Dockerfile', ref=branch_name) f = p.files.get(file_path='Dockerfile', ref=branch_name)
return _from_rx.findall(f.decode().decode('utf-8')) return _from_rx.findall(f.decode().decode('utf-8'))
...@@ -60,7 +64,11 @@ def get_docker_deps(gl, project_path, branch_name): ...@@ -60,7 +64,11 @@ def get_docker_deps(gl, project_path, branch_name):
def get_explicit_deps(gl, project_path, branch_name): def get_explicit_deps(gl, project_path, branch_name):
try:
p = gl.projects.get(project_path) p = gl.projects.get(project_path)
except Exception as e:
logging.error('error accessing project %s: %s', project_path, e)
return []
try: try:
f = p.files.get(file_path='.gitlab-deps', ref=branch_name) f = p.files.get(file_path='.gitlab-deps', ref=branch_name)
return f.decode().decode('utf-8').split('\n') return f.decode().decode('utf-8').split('\n')
...@@ -80,7 +88,6 @@ def docker_image_to_project(docker_image, registry_hostname): ...@@ -80,7 +88,6 @@ def docker_image_to_project(docker_image, registry_hostname):
else: else:
branch = m[5] branch = m[5]
return m[3], branch return m[3], branch
return None, None
_url_rx = re.compile(r'^(https?://[^/]+/)([^:]+)(:.*)?$') _url_rx = re.compile(r'^(https?://[^/]+/)([^:]+)(:.*)?$')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment