Skip to content

Commit

Permalink
Fix finding component target function
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiltd committed Oct 16, 2024
1 parent 9590ecc commit d3d8957
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/containerd-shim-wasmtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ impl<'a> ComponentTarget<'a> {
I: IntoIterator<Item = (&'b str, ComponentItem)> + 'b,
{
// This is heuristic but seems to work
let has_http_handler = exports
exports
.into_iter()
.any(|(name, _)| name.starts_with("wasi:http/incoming-handler"));

match (func, has_http_handler) {
("_start", false) => Self::Command,
("_start", true) => Self::HttpProxy,
_ => Self::Core(func),
}
.find_map(|(name, _)| {
if name.starts_with("wasi:http/incoming-handler") {
Some(Self::HttpProxy)
} else if name.starts_with("wasi:cli/run") {
Some(Self::Command)
} else {
None
}
})
.unwrap_or(Self::Core(func))
}
}

Expand Down

0 comments on commit d3d8957

Please sign in to comment.