bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.2k stars 4.06k forks source link

Add support for git SSH registry URL #22456

Open Annrtl opened 5 months ago

Annrtl commented 5 months ago

Description of the feature request:

Be able to use a git SSH registry URL Example in .bazelrc:

common --registry=git@github.com:bazelbuild/bazel-central-registry.git

Which category does this issue belong to?

No response

What underlying problem are you trying to solve with this feature?

Add a private git repository protected by ssh key as Bazel register

Which operating system are you running Bazel on?

Rocky Linux 9.4 (Blue Onyx)

What is the output of bazel info release?

release 7.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

Using a git SSH registry URL gives me the following error message

Invalid registry URL: Unrecognized registry URL protocol
BalestraPatrick commented 3 months ago

@fmeum Do you have any instructions/ideas on how to achieve this? I see this as a blocker for us to adopt bzlmod since we don't want to use the credentials helper to distribute personal access tokens (but rather rely on the already configured ssh key) to access a private git repository.

fmeum commented 3 months ago

Since the registry model is heavy on random access to specific paths, I'm not sure Bazel could do better than checking out the repo completely to some local path and then using that as the registry. This poses the non-trivial problem of when to fetch and check for updates to the remote repo.

Could you include this logic into your tools/bazel wrapper and just point Bazel to the local path to which your wrapper clones it? That should give you essentially the same user experience today, plus you would have full control over when to git fetch.

BalestraPatrick commented 1 month ago

@fmeum I can see how that would work, but it's also extra logic that every user of Bazel now has to take care of implementing. Even if there was a way to just create a git_repository and hook that up to be a registry, that would be much more ideal. Or possibly a way to adopt a registry via a downloaded zip file that we could produce by packaging up the internal repo and make that even more cacheable and reproducible?