Skip to content

Commit accb43b

Browse files
committed
Extend parsing logic to other handlers
Signed-off-by: Varsha U N <[email protected]>
1 parent 610689c commit accb43b

16 files changed

+148
-205
lines changed

src/packagedcode/dockerfile.py renamed to src/packagedcode/dockerfile_ocilabels.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@
1111

1212
import io
1313
from pathlib import Path
14-
from dockerfile_parse import DockerfileParser
14+
from dockerfile_parse import DockerfileParser
1515
from packagedcode import models
1616
from packagedcode import utils
17+
from packagedcode.models import NonAssemblableDatafileHandler
1718
import fnmatch
1819

1920

20-
class DockerfileHandler(models.DatafileHandler):
21+
class DockerOCILabelsHandler(NonAssemblableDatafileHandler):
2122
datasource_id = 'dockerfile_oci_labels'
22-
23-
@classmethod
24-
def is_datafile(cls, path):
25-
patterns = ['Dockerfile', 'containerfile', '*.dockerfile']
26-
filename=os.path.basename(path)
27-
for pattern in patterns:
28-
if fnmatch.fnmatch(filename, pattern):
29-
return True
30-
return False
23+
path_patterns = ('Dockerfile', 'containerfile', '*.dockerfile')
3124

3225
@classmethod
3326
def parse(cls, location, package_only=False):
@@ -38,10 +31,10 @@ def parse(cls, location, package_only=False):
3831
package_data = {
3932
'datasource_id': cls.datasource_id,
4033
'type': cls.default_package_type,
41-
'name': labels.get('name', 'None'),
42-
'version': labels.get('version', 'None'),
43-
'license_expression': labels.get('license', 'None'),
44-
'labels': labels,
34+
'name': labels.get('name', 'None'),
35+
'version': labels.get('version', 'None'),
36+
'license_expression': labels.get('license'),
37+
'labels': labels,
4538
}
4639

4740
yield models.PackageData.from_data(package_data, package_only)
Binary file not shown.

tests/packagedcode/data/docker/psql-expected.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/packagedcode/data/docker/psql.dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#Copied from https://github.com/kubernetes-sigs/blixt/blob
2+
3+
FROM alpine
4+
5+
WORKDIR /opt/blixt/
6+
7+
LABEL org.opencontainers.image.source=https://github.com/kubernetes-sigs/blixt
8+
LABEL org.opencontainers.image.licenses=GPL-2.0-only,BSD-2-Clause
9+
10+
COPY dataplane/LICENSE.GPL-2.0 /opt/blixt/LICENSE.GPL-2.0
11+
COPY dataplane/LICENSE.BSD-2-Clause /opt/blixt/LICENSE.BSD-2-Clause
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"datasource_id": "docker_oci_labels",
4+
"labels": {
5+
"org.opencontainers.image.source": "https://github.com/kubernetes-sigs/blixt",
6+
"org.opencontainers.image.licenses": "GPL-2.0-only,BSD-2-Clause"
7+
}
8+
}
9+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"datasource_id": "docker_oci_labels",
3+
"labels": {
4+
"org.opencontainers.image.source": "https://github.com/kubernetes-sigs/blixt",
5+
"org.opencontainers.image.licenses": "GPL-2.0-only,BSD-2-Clause"
6+
}
7+
}

tests/packagedcode/data/docker/test-dockerfile-expected.json

Lines changed: 0 additions & 18 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
#Copied from https://github.com/kanboard/kanboard
22

33
FROM alpine:3.21
4-
5-
LABEL org.opencontainers.image.source https://github.com/kanboard/kanboard
4+
LABEL org.opencontainers.image.source=https://github.com/kanboard/kanboard
65
LABEL org.opencontainers.image.title=Kanboard
76
LABEL org.opencontainers.image.description="Kanboard is project management software that focuses on the Kanban methodology"
87
LABEL org.opencontainers.image.vendor=Kanboard
98
LABEL org.opencontainers.image.licenses=MIT
109
LABEL org.opencontainers.image.url=https://kanboard.org
1110
LABEL org.opencontainers.image.documentation=https://docs.kanboard.org
12-
1311
VOLUME /var/www/app/data
1412
VOLUME /var/www/app/plugins
1513
VOLUME /etc/nginx/ssl
16-
1714
EXPOSE 80 443
18-
1915
ARG VERSION
20-
21-
RUN apk --no-cache --update add \
22-
tzdata openssl unzip nginx bash ca-certificates s6 curl ssmtp mailx php83 php83-phar php83-curl \
23-
php83-fpm php83-json php83-zlib php83-xml php83-dom php83-ctype php83-opcache php83-zip php83-iconv \
24-
php83-pdo php83-pdo_mysql php83-pdo_sqlite php83-pdo_pgsql php83-mbstring php83-session php83-bcmath \
25-
php83-gd php83-openssl php83-sockets php83-posix php83-ldap php83-simplexml php83-xmlwriter && \
26-
rm -rf /var/www/localhost && \
27-
rm -f /etc/php83/php-fpm.d/www.conf && \
28-
ln -sf /usr/bin/php83 /usr/bin/php
29-
16+
RUN apk --no-cache --update add ...
3017
ADD . /var/www/app
3118
ADD docker/ /
32-
3319
RUN rm -rf /var/www/app/docker && echo $VERSION > /var/www/app/app/version.txt
34-
3520
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
3621
CMD []

0 commit comments

Comments
 (0)