Skip to content

Commit

Permalink
Merge pull request #3722 from wasmerio/revert-3715
Browse files Browse the repository at this point in the history
Revert #3715
  • Loading branch information
Michael Bryan authored Mar 30, 2023
2 parents 4ccbc4b + 2c779dc commit 9d7f7a3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ wasm-coredump-builder = { version = "0.1.11" }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", features = [ "env-filter", "fmt" ] }
clap-verbosity-flag = "1"
wapm-targz-to-pirita = "0.1.7"
wapm-targz-to-pirita = "0.1.10"

[target.'cfg(not(target_arch = "riscv64"))'.dependencies]
http_req = { version="^0.8", default-features = false, features = ["rust-tls"] }
Expand Down
12 changes: 3 additions & 9 deletions lib/wasi/src/runners/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ impl crate::runners::Runner for WasiRunner {
command: &Command,
container: &WapmContainer,
) -> Result<Self::Output, Error> {
let Annotations { wasi } = command
.get_annotation(webc::metadata::annotations::WASI_RUNNER_URI)?
.unwrap_or_default();
let wasi = wasi.unwrap_or_else(|| Wasi::new(command_name));
let wasi = command
.get_annotation("wasi")?
.unwrap_or_else(|| Wasi::new(command_name));
let atom_name = &wasi.atom;
let atom = container
.get_atom(atom_name)
Expand All @@ -169,8 +168,3 @@ impl crate::runners::Runner for WasiRunner {
Ok(())
}
}

#[derive(Default, Debug, serde::Deserialize)]
struct Annotations {
wasi: Option<Wasi>,
}
25 changes: 8 additions & 17 deletions lib/wasi/src/runners/wcgi/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,17 @@ impl WcgiRunner {

#[tracing::instrument(skip(self, ctx))]
fn run(&mut self, command_name: &str, ctx: &RunnerContext<'_>) -> Result<(), Error> {
let key = webc::metadata::annotations::WCGI_RUNNER_URI;
let Annotations { wasi, wcgi } = ctx
let wasi: Wasi = ctx
.command()
.get_annotation(key)
.with_context(|| format!("Unable to deserialize the \"{key}\" annotations"))?
.unwrap_or_default();

let wasi = wasi.unwrap_or_else(|| Wasi::new(command_name));
.get_annotation("wasi")
.context("Unable to retrieve the WASI metadata")?
.unwrap_or_else(|| Wasi::new(command_name));

let module = self
.load_module(&wasi, ctx)
.context("Couldn't load the module")?;

let handler = self.create_handler(module, &wasi, &wcgi, ctx)?;
let handler = self.create_handler(module, &wasi, ctx)?;
let task_manager = Arc::clone(&handler.task_manager);
let callbacks = Arc::clone(&self.config.callbacks);

Expand Down Expand Up @@ -129,10 +126,11 @@ impl WcgiRunner {
&self,
module: Module,
wasi: &Wasi,
wcgi: &Wcgi,
ctx: &RunnerContext<'_>,
) -> Result<Handler, Error> {
let dialect = match &wcgi.dialect {
let Wcgi { dialect, .. } = ctx.command().get_annotation("wcgi")?.unwrap_or_default();

let dialect = match dialect {
Some(d) => d.parse().context("Unable to parse the CGI dialect")?,
None => CgiDialect::Wcgi,
};
Expand Down Expand Up @@ -344,13 +342,6 @@ impl Default for Config {
}
}

#[derive(Debug, Default, serde::Deserialize)]
struct Annotations {
wasi: Option<Wasi>,
#[serde(default)]
wcgi: Wcgi,
}

/// Callbacks that are triggered at various points in the lifecycle of a runner
/// and any WebAssembly instances it may start.
pub trait Callbacks: Send + Sync + 'static {
Expand Down

0 comments on commit 9d7f7a3

Please sign in to comment.