From cde2bb026b8fcac2e6049a41cb634fb2d661dcb8 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Tue, 15 Aug 2023 22:42:12 +0000 Subject: [PATCH] Follow up to #219 and #156 Signed-off-by: James Sturtevant --- crates/containerd-shim-wasmedge/src/executor.rs | 15 ++++++--------- crates/containerd-shim-wasmtime/src/executor.rs | 15 ++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/crates/containerd-shim-wasmedge/src/executor.rs b/crates/containerd-shim-wasmedge/src/executor.rs index 0660cb11f..7cf591ec1 100644 --- a/crates/containerd-shim-wasmedge/src/executor.rs +++ b/crates/containerd-shim-wasmedge/src/executor.rs @@ -55,15 +55,12 @@ impl Executor for WasmEdgeExecutor { fn can_handle(&self, spec: &Spec) -> bool { // check if the entrypoint of the spec is a wasm binary. - let args = oci::get_args(spec); - if args.is_empty() { - return false; - } - - let start = args[0].clone(); - let mut iterator = start.split('#'); - let cmd = iterator.next().unwrap().to_string(); - let path = PathBuf::from(cmd); + let (module_name, _method) = oci::get_module(spec); + let module_name = match module_name { + Some(m) => m, + None => return false, + }; + let path = PathBuf::from(module_name); path.extension() .map(|ext| ext.to_ascii_lowercase()) diff --git a/crates/containerd-shim-wasmtime/src/executor.rs b/crates/containerd-shim-wasmtime/src/executor.rs index 1f935afb0..da0079764 100644 --- a/crates/containerd-shim-wasmtime/src/executor.rs +++ b/crates/containerd-shim-wasmtime/src/executor.rs @@ -57,15 +57,12 @@ impl Executor for WasmtimeExecutor { fn can_handle(&self, spec: &Spec) -> bool { // check if the entrypoint of the spec is a wasm binary. - let args = oci::get_args(spec); - if args.is_empty() { - return false; - } - - let start = args[0].clone(); - let mut iterator = start.split('#'); - let cmd = iterator.next().unwrap().to_string(); - let path = PathBuf::from(cmd); + let (module_name, _method) = oci::get_module(spec); + let module_name = match module_name { + Some(m) => m, + None => return false, + }; + let path = PathBuf::from(module_name); // TODO: do we need to validate the wasm binary? // ```rust