Skip to content

Commit aaaea73

Browse files
committed
Resolve comments
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
1 parent a28fad9 commit aaaea73

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

crates/containerd-shim-wasmtime/src/executor.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use nix::unistd::{dup, dup2};
22
use std::{fs::OpenOptions, os::fd::RawFd};
33

4-
use anyhow::{anyhow, Result};
4+
use anyhow::{anyhow, Result, Context};
55
use containerd_shim_wasm::sandbox::oci;
66
use libc::{STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO};
77
use libcontainer::workload::{Executor, ExecutorError};
@@ -24,7 +24,7 @@ pub struct WasmtimeExecutor {
2424
impl Executor for WasmtimeExecutor {
2525
fn exec(&self, spec: &Spec) -> Result<(), ExecutorError> {
2626
let args = oci::get_args(spec);
27-
if args.is_empty() {
27+
if args.len() != 1 {
2828
return Err(ExecutorError::InvalidArg);
2929
}
3030

@@ -82,8 +82,10 @@ impl WasmtimeExecutor {
8282
let wctx = wasi_builder.build();
8383

8484
log::info!("wasi context ready");
85-
let start = args[0].clone();
86-
let mut iterator = start.split('#');
85+
let mut iterator = args
86+
.first()
87+
.context("args must have at least one argument.")?
88+
.split('#');
8789
let mut cmd = iterator.next().unwrap().to_string();
8890
let stripped = cmd.strip_prefix(std::path::MAIN_SEPARATOR);
8991
if let Some(strpd) = stripped {

0 commit comments

Comments
 (0)