Registries
Registries are sources where bz reads module metadata and content. bz supports several registry types.
HTTP Registry
Connect to any BCR-compatible HTTP registry:
# Bazel Central Registrybcr = registry.http("https://bcr.bazel.build")
# Custom HTTP registryinternal = registry.http("https://registry.internal.example.com")With Authentication
private_registry = registry.http( url = "https://private.example.com", auth = auth.bearer(token = env("REGISTRY_TOKEN")),)File Registry
Read from a local filesystem path:
# Absolute pathlocal = registry.file("/var/bazel-registry")
# Relative path (from config file location)local = registry.file("./bazel-registry")
# Home directorylocal = registry.file("~/bazel-registry")Git Registry
Clone and read from a git repository:
# Public repositorybcr_fork = registry.git( url = "https://github.com/myorg/bazel-central-registry.git",)
# With specific branchbcr_fork = registry.git( url = "https://github.com/myorg/bazel-central-registry.git", branch = "custom-modules",)
# With authenticationprivate_repo = registry.git( url = "https://github.com/myorg/private-registry.git", auth = auth.bearer(token = env("GITHUB_TOKEN")),)Registry Structure
All registries must follow the BCR directory structure:
modules/├── rules_go/│ ├── metadata.json│ ├── 0.50.0/│ │ ├── MODULE.bazel│ │ └── source.json│ └── 0.50.1/│ ├── MODULE.bazel│ └── source.json└── rules_python/ ├── metadata.json └── ...metadata.json
Contains module metadata:
{ "versions": ["0.50.0", "0.50.1"], "yanked_versions": {}}MODULE.bazel
The module’s Bazel module file.
source.json
Specifies how to fetch the module source:
{ "url": "https://github.com/org/repo/archive/v0.50.1.tar.gz", "integrity": "sha256-...", "strip_prefix": "repo-0.50.1"}Registry Methods
All registry types support these methods:
| Method | Description |
|---|---|
GetMetadata(module) | Get module metadata |
GetModuleBazel(module, version) | Get MODULE.bazel content |
GetSource(module, version) | Get source.json content |
ListModules() | List all modules (if supported) |
Examples
Multiple Registries
# Primary: Bazel Central Registrybcr = registry.http("https://bcr.bazel.build")
# Fallback: Internal mirrormirror = registry.http("https://bcr-mirror.internal")
# Custom modulescustom = registry.file("/opt/custom-modules")Development Setup
# Use local BCR fork for developmentbcr_dev = registry.file("../bazel-central-registry")
# Or use git with a feature branchbcr_feature = registry.git( url = "https://github.com/myuser/bazel-central-registry.git", branch = "add-new-module",)