Skip to content

Commit

Permalink
feat(model): Extend Identifier.toPurl() with handling for Bazel
Browse files Browse the repository at this point in the history
See also [1].

[1]: package-url/purl-spec#317

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Nov 22, 2024
1 parent 1d5676f commit 4606136
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 50 deletions.
1 change: 1 addition & 0 deletions model/src/main/kotlin/utils/PurlExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.ossreviewtoolkit.model.VcsType
*/
fun Identifier.getPurlType() =
when (type.lowercase()) {
"bazel" -> PurlType.BAZEL

Check warning on line 41 in model/src/main/kotlin/utils/PurlExtensions.kt

View check run for this annotation

Codecov / codecov/patch

model/src/main/kotlin/utils/PurlExtensions.kt#L41

Added line #L41 was not covered by tests
"bower" -> PurlType.BOWER
"carthage" -> PurlType.CARTHAGE
"composer" -> PurlType.COMPOSER
Expand Down
1 change: 1 addition & 0 deletions model/src/main/kotlin/utils/PurlUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.ossreviewtoolkit.utils.common.percentEncode
enum class PurlType(private val value: String) {
ALPINE("alpine"),
A_NAME("a-name"),
BAZEL("bazel"),
BOWER("bower"),
CARGO("cargo"),
CARTHAGE("carthage"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::abseil-cpp:20230125.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -78,7 +78,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::bazel_skylib:1.6.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -104,7 +104,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::gflags:2.2.2"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -130,7 +130,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::glog:0.5.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -156,7 +156,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::googletest:1.14.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -182,7 +182,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::platforms:0.0.9"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -208,7 +208,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_cc:0.0.9"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -234,7 +234,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_license:0.0.7"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::abseil-cpp:20230802.0.bcr.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -209,7 +209,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::bazel_features:1.9.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -235,7 +235,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::bazel_skylib:1.7.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -261,7 +261,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::googletest:1.14.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -287,7 +287,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::nanopb:0.4.9"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -313,7 +313,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::platforms:0.0.10"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -339,7 +339,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::protobuf:24.4"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -365,7 +365,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_cc:0.0.9"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -391,7 +391,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_cuda:0.1.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -418,7 +418,7 @@ packages:
path: ""
is_modified: true
- id: "Bazel::rules_java:7.1.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -444,7 +444,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_jvm_external:5.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -470,7 +470,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_license:0.0.7"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -496,7 +496,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_pkg:0.7.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -522,7 +522,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_proto:6.0.2"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -548,7 +548,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_proto_grpc:5.0.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -574,7 +574,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::rules_python:0.34.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -600,7 +600,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::stardoc:0.5.3"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -626,7 +626,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::toolchains_protoc:0.3.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -652,7 +652,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::upb:0.0.0-20230516-61a97ef"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -678,7 +678,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::zlib:1.3"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::module_c:0.0.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::gflags:2.2.2"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -55,7 +55,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::glog:0.5.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -81,7 +81,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::test_module:0.0.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::gflags:2.2.2"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -55,7 +55,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::glog:0.5.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -81,7 +81,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::test_module:0.0.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::gflags:2.2.2"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -55,7 +55,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::glog:0.5.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -81,7 +81,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::test_module:0.0.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ analyzer:
linkage: "STATIC"
packages:
- id: "Bazel::module_a:0.0.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -79,7 +79,7 @@ analyzer:
revision: ""
path: ""
- id: "Bazel::module_b:0.0.1"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ project:
linkage: "STATIC"
packages:
- id: "Bazel::gflags:2.2.2"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand All @@ -53,7 +53,7 @@ packages:
revision: ""
path: ""
- id: "Bazel::glog:0.5.0"
purl: "pkg:generic/[email protected]"
purl: "pkg:bazel/[email protected]"
declared_licenses: []
declared_licenses_processed: {}
description: ""
Expand Down
Loading

0 comments on commit 4606136

Please sign in to comment.