Skip to content

Commit 7a785ea

Browse files
committed
updated dockerfile.py
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
1 parent cd4498d commit 7a785ea

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/packagedcode/dockerfile.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ class DockerfileHandler(models.DatafileHandler):
2323
@classmethod
2424
def is_datafile(cls, path):
2525
patterns = ['Dockerfile', 'containerfile', '*.dockerfile']
26+
filename=os.path.basename(path)
2627
for pattern in patterns:
27-
if fnmatch.fnmatch(path, pattern):
28+
if fnmatch.fnmatch(filename, pattern):
2829
return True
29-
return False
30+
return False
3031

3132
@classmethod
3233
def parse(cls, location, package_only=False):
@@ -48,10 +49,11 @@ def parse(cls, location, package_only=False):
4849
@classmethod
4950
def extract_oci_labels_from_dockerfile(cls, dockerfile_path):
5051
"""
51-
Extract OCI labels from the Dockerfile using container-inspector.
52+
Extract OCI labels from the Dockerfile using DockerfileParser.
5253
"""
5354
labels = {}
5455
parser = DockerfileParser()
55-
parser.parse(dockerfile_path)
56-
labels = parser.labels
56+
with open(dockerfile_path, 'r') as dockerfile:
57+
parser.content = dockerfile.read()
58+
labels = parser.labels
5759
return labels

0 commit comments

Comments
 (0)