Skip to content

Commit

Permalink
feat(bazel): Support multiple registry services
Browse files Browse the repository at this point in the history
For Bazel < 7.2.0, if the `.bazelrc` file lists multiple registries,
use all of them to query package metadata.

Fixes #8801.

Signed-off-by: Oliver Heger <oliver.heger@bosch.io>
  • Loading branch information
oheger-bosch committed Aug 6, 2024
1 parent ebd6454 commit 378f6e2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,51 @@ packages:
declared_licenses: []
declared_licenses_processed: {}
description: ""
homepage_url: ""
homepage_url: "https://gflags.github.io/gflags/"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz"
hash:
value: ""
algorithm: ""
value: "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf"
algorithm: "SHA-256"
vcs:
type: ""
url: ""
type: "Git"
url: "https://github.com/gflags/gflags"
revision: ""
path: ""
vcs_processed:
type: ""
url: ""
type: "Git"
url: "https://github.com/gflags/gflags.git"
revision: ""
path: ""
- id: "Bazel::glog:0.5.0"
purl: "pkg:generic/glog@0.5.0"
declared_licenses: []
declared_licenses_processed: {}
description: ""
homepage_url: ""
homepage_url: "https://github.com/google/glog"
binary_artifact:
url: ""
hash:
value: ""
algorithm: ""
source_artifact:
url: ""
url: "https://github.com/google/glog/archive/refs/tags/v0.5.0.tar.gz"
hash:
value: ""
algorithm: ""
value: "eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5"
algorithm: "SHA-256"
vcs:
type: ""
url: ""
type: "Git"
url: "https://github.com/google/glog"
revision: ""
path: ""
vcs_processed:
type: ""
url: ""
type: "Git"
url: "https://github.com/google/glog.git"
revision: ""
path: ""
- id: "Bazel::test_module:0.0.1"
Expand Down
5 changes: 1 addition & 4 deletions plugins/package-managers/bazel/src/main/kotlin/Bazel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ class Bazel(
private fun determineRegistry(lockfile: Lockfile, projectDir: File): BazelModuleRegistryService {
// Bazel version < 7.2.0.
if (lockfile.flags != null) {
val registryUrl = lockfile.registryUrl()

return LocalBazelModuleRegistryService.createForLocalUrl(registryUrl, projectDir)
?: RemoteBazelModuleRegistryService.create(registryUrl)
return MultiBazelModuleRegistryService.create(lockfile.registryUrls(), projectDir)
}

// Bazel version >= 7.2.0.
Expand Down
7 changes: 5 additions & 2 deletions plugins/package-managers/bazel/src/main/kotlin/BazelModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ internal data class Lockfile(
}
}

// TODO Support multiple registries.
fun registryUrl(): String? = flags?.cmdRegistries?.getOrElse(0) { null }
/**
* Return a collection with the URLs of the service registries defined for this project in case the model for
* Bazel < 7.2.0 is used.
*/
fun registryUrls(): Collection<String> = flags?.cmdRegistries.orEmpty()
}

@Serializable
Expand Down

0 comments on commit 378f6e2

Please sign in to comment.