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

propose bazel type for Bazel modules #317

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions PURL-TYPES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ apk
pkg:apk/alpine/curl@7.83.0-r0?arch=x86
pkg:apk/alpine/apk@2.12.9-r3?arch=x86

bazel
-----
``bazel`` for Bazel modules:

- The default repository ("registry") is ``https://bcr.bazel.build``, the
fmeum marked this conversation as resolved.
Show resolved Hide resolved
Bazel Central Registry (BCR).
- The ``name`` is the module name. It must be lowercased.
- The ``version`` is the module version in `Bazel's relaxed semver format
<https://bazel.build/external/module#version_format>`_.
- The optional ``repository_url`` can be used to specify the URL of an
alternative registry, with any trailing forward slashes removed.
Copy link
Member

Choose a reason for hiding this comment

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

with any trailing forward slashes removed.

I'm not sure about that bit. This is not one of the "type-specific normalizations" that are allowed for the namespace segments and name. And semantically, having a trailing slash or not does not make a difference for the URL.

Copy link
Author

Choose a reason for hiding this comment

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

I just dropped this in a new commit.

- The optional ``subpath`` can name a particular Bazel target in the module via
a label with the leading double slash (``//``) removed and canonicalized by
omitting the target name if it is equal to the name of the containing package.
Copy link
Member

Choose a reason for hiding this comment

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

Hmm. The spec describes the subpath as

extra subpath within a package, relative to the package root.

How is what you describe "relative to the package root"? Would a custom qualifier maybe make more sense to store the Bazel target?

Copy link
Author

Choose a reason for hiding this comment

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

I simplified this part of the spec in a new commit so that it's always a regular file path, corresponding to a package (not target or file) in the Bazel module. This is analogous to the usage of subpath for golang.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me now, but I'd like others to share their opinion as well.

- Examples::

pkg:bazel/rules_java@7.8.0
pkg:bazel/curl@8.8.0.bcr.1
pkg:bazel/curl@8.8.0?repository_url=https://example.org/bazel-registry
pkg:bazel/rules_java@7.8.0
pkg:bazel/rules_java@7.8.0#toolchains:singlejar
pkg:bazel/rules_go@0.48.0#go

bitbucket
---------
``bitbucket`` for Bitbucket-based packages:
Expand Down
84 changes: 84 additions & 0 deletions test-suite-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,5 +622,89 @@
"qualifiers": null,
"subpath": null,
"is_invalid": false
},
{
"description": "bazel module with default registry",
"purl": "pkg:bazel/rules_java@7.8.0?registry_url=https://bcr.bazel.build/",
"canonical_purl": "pkg:bazel/rules_java@7.8.0",
"type": "bazel",
"namespace": null,
"name": "rules_java",
"version": "7.8.0",
"qualifiers": null,
"subpath": null,
"is_invalid": false
},
{
"description": "bazel module with custom registry",
"purl": "pkg:bazel/rules_java@7.8.0?registry_url=https://example.org/bazel-registry/",
"canonical_purl": "pkg:bazel/rules_java@7.8.0?registry_url=https://example.org/bazel-registry",
"type": "bazel",
"namespace": null,
"name": "rules_java",
"version": "7.8.0",
"qualifiers": null,
"subpath": null,
"is_invalid": false
},
{
"description": "bazel module with relaxed semver version",
"purl": "pkg:bazel/curl@8.8.0.bcr.1",
"canonical_purl": "pkg:bazel/curl@8.8.0.bcr.1",
"type": "bazel",
"namespace": null,
"name": "curl",
"version": "8.8.0.bcr.1",
"qualifiers": null,
"subpath": null,
"is_invalid": false
},
{
"description": "bazel module names are lowercased",
"purl": "pkg:bazel/Curl@8.8.0.bcr.1",
"canonical_purl": "pkg:bazel/Curl@8.8.0.bcr.1",
"type": "bazel",
"namespace": null,
"name": "curl",
"version": "8.8.0.bcr.1",
"qualifiers": null,
"subpath": null,
"is_invalid": true
},
{
"description": "bazel module with target",
"purl": "pkg:bazel/rules_java@7.8.0#//toolchains:singlejar",
"canonical_purl": "pkg:bazel/rules_java@7.8.0#toolchains:singlejar",
"type": "bazel",
"namespace": null,
"name": "rules_java",
"version": "7.8.0",
"qualifiers": null,
"subpath": "toolchains:singlejar",
"is_invalid": false
},
{
"description": "bazel module with target in short-hand form",
"purl": "pkg:bazel/rules_go@0.48.0#//go:go",
"canonical_purl": "pkg:bazel/rules_go@0.48.0#go",
"type": "bazel",
"namespace": null,
"name": "rules_go",
"version": "0.48.0",
"qualifiers": null,
"subpath": "go",
"is_invalid": false
},
{
"description": "bazel module with top-level target",
"purl": "pkg:bazel/rules_go@0.48.0#//:stdlib",
"canonical_purl": "pkg:bazel/rules_go@0.48.0#:stdlib",
"type": "bazel",
"namespace": null,
"name": "rules_go",
"version": "0.48.0",
"qualifiers": null,
"subpath": ":stdlib",
"is_invalid": false
}
]