Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use common library function for getting the module name #242

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/containerd-shim-wasmedge/src/executor.rs
Original file line number Diff line number Diff line change
@@ -55,15 +55,15 @@ 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 => {
log::info!("WasmEdge cannot handle this workload, no arguments provided");
return false;
}
};
let path = PathBuf::from(module_name);

path.extension()
.map(|ext| ext.to_ascii_lowercase())
18 changes: 9 additions & 9 deletions crates/containerd-shim-wasmtime/src/executor.rs
Original file line number Diff line number Diff line change
@@ -57,15 +57,15 @@ 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 => {
log::info!("Wasmtime cannot handle this workload, no arguments provided");
return false;
}
};
let path = PathBuf::from(module_name);

// TODO: do we need to validate the wasm binary?
// ```rust