Skip to content

Commit

Permalink
fix(client): Fixes source resolution package overrides
Browse files Browse the repository at this point in the history
If someone passes metadata for an override, we needed to use that instead

Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
  • Loading branch information
thomastaylor312 committed Oct 2, 2024
1 parent 02f892c commit f0b0108
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.7.2"
version = "0.7.3"
authors = ["The Wasmtime Project Developers"]
license = "Apache-2.0 WITH LLVM-exception"

Expand Down Expand Up @@ -36,9 +36,9 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
"fmt",
"env-filter",
] }
wasm-pkg-common = { version = "0.7.2", path = "crates/wasm-pkg-common" }
wasm-pkg-client = { version = "0.7.2", path = "crates/wasm-pkg-client" }
wasm-pkg-common = { version = "0.7.3", path = "crates/wasm-pkg-common" }
wasm-pkg-client = { version = "0.7.3", path = "crates/wasm-pkg-client" }
wasm-metadata = "0.217"
wit-component = "0.217"
wit-parser = "0.217"
wasm-pkg-core = { version = "0.7.2", path = "crates/wasm-pkg-core" }
wasm-pkg-core = { version = "0.7.3", path = "crates/wasm-pkg-core" }
36 changes: 24 additions & 12 deletions crates/wasm-pkg-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,30 @@ impl Client {
let should_fetch_meta = registry_config.default_backend() != Some("local");
let maybe_metadata = self
.config
.namespace_registry(package.namespace())
.and_then(|meta| {
// If the overriden registry matches the registry we are trying to resolve, we
// should use the metadata, otherwise we'll need to fetch the metadata from the
// registry
match (meta, is_override) {
(RegistryMapping::Custom(custom), true) if custom.registry == registry => {
Some(custom.metadata.clone())
}
(RegistryMapping::Custom(custom), false) => Some(custom.metadata.clone()),
_ => None,
}
.package_registry_override(package)
.and_then(|mapping| match mapping {
RegistryMapping::Custom(custom) => Some(custom.metadata.clone()),
_ => None,
})
.or_else(|| {
self.config
.namespace_registry(package.namespace())
.and_then(|meta| {
// If the overriden registry matches the registry we are trying to resolve, we
// should use the metadata, otherwise we'll need to fetch the metadata from the
// registry
match (meta, is_override) {
(RegistryMapping::Custom(custom), true)
if custom.registry == registry =>
{
Some(custom.metadata.clone())
}
(RegistryMapping::Custom(custom), false) => {
Some(custom.metadata.clone())
}
_ => None,
}
})
});

let registry_meta = if let Some(meta) = maybe_metadata {
Expand Down

0 comments on commit f0b0108

Please sign in to comment.