Commit 5aa7f23a authored by ale's avatar ale
Browse files

Scan Containerfile as well as Dockerfile for dependencies

parent e174d7fc
...@@ -48,6 +48,10 @@ def has_ci(gl, project_path, branch_name): ...@@ -48,6 +48,10 @@ def has_ci(gl, project_path, branch_name):
_from_rx = re.compile(r'^FROM\s+(\S+).*$', re.MULTILINE) _from_rx = re.compile(r'^FROM\s+(\S+).*$', re.MULTILINE)
_dockerfiles = [
'Dockerfile',
'Containerfile',
]
def get_docker_deps(gl, project_path, branch_name): def get_docker_deps(gl, project_path, branch_name):
...@@ -56,11 +60,16 @@ def get_docker_deps(gl, project_path, branch_name): ...@@ -56,11 +60,16 @@ def get_docker_deps(gl, project_path, branch_name):
except Exception as e: except Exception as e:
logging.error('error accessing project %s: %s', project_path, e) logging.error('error accessing project %s: %s', project_path, e)
return [] return []
try: def _parse_dockerfile(file_path):
f = p.files.get(file_path='Dockerfile', ref=branch_name) try:
return _from_rx.findall(f.decode().decode('utf-8')) f = p.files.get(file_path=file_path, ref=branch_name)
except Exception: return _from_rx.findall(f.decode().decode('utf-8'))
return [] except Exception:
return []
out = []
for file_path in _dockerfiles:
out.extend(_parse_dockerfile(file_path))
return out
def get_explicit_deps(gl, project_path, branch_name): def get_explicit_deps(gl, project_path, branch_name):
......
Supports Markdown
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