From 5aa7f23ae8226f4925c7946f8ccde67733347ce8 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Thu, 10 Dec 2020 14:28:58 +0000
Subject: [PATCH] Scan Containerfile as well as Dockerfile for dependencies

---
 gitlab_deps/deps.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gitlab_deps/deps.py b/gitlab_deps/deps.py
index a00fe73..76068e4 100644
--- a/gitlab_deps/deps.py
+++ b/gitlab_deps/deps.py
@@ -48,6 +48,10 @@ def has_ci(gl, project_path, branch_name):
 
 
 _from_rx = re.compile(r'^FROM\s+(\S+).*$', re.MULTILINE)
+_dockerfiles = [
+    'Dockerfile',
+    'Containerfile',
+]
 
 
 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:
         logging.error('error accessing project %s: %s', project_path, e)
         return []
-    try:
-        f = p.files.get(file_path='Dockerfile', ref=branch_name)
-        return _from_rx.findall(f.decode().decode('utf-8'))
-    except Exception:
-        return []
+    def _parse_dockerfile(file_path):
+        try:
+            f = p.files.get(file_path=file_path, ref=branch_name)
+            return _from_rx.findall(f.decode().decode('utf-8'))
+        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):
-- 
GitLab