Skip to content

Commit

Permalink
updated dockerfile.py
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha U N <[email protected]>
  • Loading branch information
VarshaUN committed Dec 23, 2024
1 parent 328639b commit a6b119c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/packagedcode/dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class DockerfileHandler(models.DatafileHandler):
@classmethod
def is_datafile(cls, path):
patterns = ['Dockerfile', 'containerfile', '*.dockerfile']
filename=os.path.basename(path)
for pattern in patterns:
if fnmatch.fnmatch(path, pattern):
if fnmatch.fnmatch(filename, pattern):
return True
return False
return False

@classmethod
def parse(cls, location, package_only=False):
Expand All @@ -48,10 +49,11 @@ def parse(cls, location, package_only=False):
@classmethod
def extract_oci_labels_from_dockerfile(cls, dockerfile_path):
"""
Extract OCI labels from the Dockerfile using container-inspector.
Extract OCI labels from the Dockerfile using DockerfileParser.
"""
labels = {}
parser = DockerfileParser()
parser.parse(dockerfile_path)
labels = parser.labels
with open(dockerfile_path, 'r') as dockerfile:
parser.content = dockerfile.read()
labels = parser.labels
return labels

0 comments on commit a6b119c

Please sign in to comment.