Skip to content

Commit

Permalink
Cargo.toml: remove unused dependnecies
Browse files Browse the repository at this point in the history
Signed-off-by: jiaxiao zhou <[email protected]>
  • Loading branch information
Mossaka committed Sep 21, 2024
1 parent 4da0be1 commit 708dcfb
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 39 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

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

7 changes: 0 additions & 7 deletions benches/containerd-shim-benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@ version.workspace = true
edition.workspace = true

[dependencies]
anyhow = { workspace = true }
chrono = { workspace = true }
containerd-shim-wasm = { path = "../../crates/containerd-shim-wasm", features = ["testing"] }
containerd-shim-wasmtime = { path = "../../crates/containerd-shim-wasmtime" }
libc = { workspace = true }
oci-spec = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tempfile = "3.8"
wasmtime = { workspace = true }

[dev-dependencies]
Expand Down
2 changes: 0 additions & 2 deletions crates/containerd-shim-wasm-test-modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ edition.workspace = true
license.workspace = true

[dependencies]
anyhow = { workspace = true }
libc = { workspace = true }

[build-dependencies]
anyhow = { workspace = true }
Expand Down
3 changes: 0 additions & 3 deletions crates/containerd-shim-wasmedge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ edition.workspace = true

[dependencies]
anyhow = { workspace = true }
containerd-shim = { workspace = true }
containerd-shim-wasm = { workspace = true }
log = { workspace = true }
oci-spec = { workspace = true, features = ["runtime"] }
ttrpc = { workspace = true }

# may need to bump wasmedge version in scripts/setup-windows.sh
wasmedge-sdk = { version = "0.13.2" }
Expand Down
4 changes: 0 additions & 4 deletions crates/containerd-shim-wasmer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ edition.workspace = true

[dependencies]
anyhow = { workspace = true }
containerd-shim = { workspace = true }
containerd-shim-wasm = { workspace = true }
log = { workspace = true }
oci-spec = { workspace = true, features = ["runtime"] }
ttrpc = { workspace = true }

tokio = "1.38.1"
wasmer = { version = "4.1.2" }
wasmer-compiler = { version = "4.1.2", features = ["compiler"] }
wasmer-wasix = { version = "0.12.0" }

[dev-dependencies]
Expand Down
4 changes: 0 additions & 4 deletions crates/containerd-shim-wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ edition.workspace = true

[dependencies]
anyhow = { workspace = true }
containerd-shim = { workspace = true }
containerd-shim-wasm = { workspace = true, features = ["opentelemetry"] }
log = { workspace = true }
oci-spec = { workspace = true, features = ["runtime"] }
ttrpc = { workspace = true }
sha256 = { workspace = true }

wasmtime = { workspace = true }
wasmtime-wasi = { workspace = true }
Expand Down
43 changes: 43 additions & 0 deletions crates/containerd-shim-wasmtime/src/component.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use containerd_shim_wasm::container::WasmBinaryType;
use wasmtime::component::Component;

use crate::instance::{WasiConfig, WasmtimeEngine};

pub(crate) enum Worlds {
WasiHTTPProxy,
WasiCLICommand,
}

impl<T> WasmtimeEngine<T>
where
T: std::clone::Clone + Sync + WasiConfig + Send + 'static,
{
pub(crate) fn detect_world(&self, component: Component) -> Worlds {
let ty = component.component_type();
for (name, _) in ty.exports(&self.engine) {
match name {
"wasi:http/[email protected]" | "wasi:http/[email protected]" => {
return Worlds::WasiHTTPProxy
}
_ => {}
}
}
Worlds::WasiCLICommand
}

// best effort to detect if the wasm component is targeting a wasi-http proxy
pub fn is_wasi_http(&self, wasm_bytes: &std::borrow::Cow<'_, [u8]>) -> anyhow::Result<bool> {
let res = match WasmBinaryType::from_bytes(wasm_bytes) {
Some(WasmBinaryType::Component) => {
let component = Component::from_binary(&self.engine, wasm_bytes)?;
match self.detect_world(component) {
Worlds::WasiHTTPProxy => true,
_ => false,
}
}
Some(_) => false,
None => false,
};
Ok(res)
}
}
Loading

0 comments on commit 708dcfb

Please sign in to comment.