Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support to parse labels in dockerfile #3987

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

VarshaUN
Copy link

Fixes #3561

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁

Signed-off-by: Varsha U N [email protected]

Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VarshaUN Thanks++

Looking good, need another round of changes and a lot more tests here for the added functionality, and this should be much better.

src/packagedcode/__init__.py Outdated Show resolved Hide resolved

import io
from pathlib import Path
from dockerfile_parse import DockerfileParser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://pypi.org/project/dockerfile-parse/ is nice to use, also note that we use this at container inspector https://github.com/aboutcode-org/container-inspector/blob/main/src/container_inspector/dockerfile.py#L14C8-L14C24 as we parse dockerfiles there too. container-inspector is also a scancode dependency, so we have to think about whether to move this code there. But overall I think this is fine here, as packagedata creation/datafile handlers should be in scancode.

I don't see this used anywhere else in scancode-toolkit, we have this in the requirements at https://github.com/aboutcode-org/scancode-toolkit/blob/develop/requirements.txt#L18 to pin the version when we import container-inspector. But we need to add dockerfile-parse here: https://github.com/aboutcode-org/scancode-toolkit/blob/develop/setup.cfg#L73 as this is not constrained at https://github.com/aboutcode-org/container-inspector/blob/main/setup.cfg#L62

src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
class DockerfileHandler(models.DatafileHandler):
datasource_id = 'dockerfile'
default_package_type = 'docker-image'
path_patterns = ('Dockerfile', 'containerfile', '*.dockerfile')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
VarshaUN and others added 8 commits December 10, 2024 20:59
Co-authored-by: Ayan Sinha Mahapatra <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Co-authored-by: Ayan Sinha Mahapatra <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Treat Dockerfile and Containerfile as "non-assembled" package data, collect OCi labels
2 participants