Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
silver-platter
gitlab-deps
Commits
5aa7f23a
Commit
5aa7f23a
authored
Dec 10, 2020
by
ale
Browse files
Scan Containerfile as well as Dockerfile for dependencies
parent
e174d7fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
gitlab_deps/deps.py
View file @
5aa7f23a
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment