Revert "wapm2pirita nests all annotations under a key with the same name as the runner"

This reverts commit 83bec095cf.
This commit is contained in:
Michael-F-Bryan
2023-03-30 21:54:40 +08:00
parent 4ccbc4b2fa
commit 09b94d9b1e
2 changed files with 11 additions and 26 deletions

View File

@@ -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)
@@ -169,8 +168,3 @@ impl crate::runners::Runner for WasiRunner {
Ok(())
}
}
#[derive(Default, Debug, serde::Deserialize)]
struct Annotations {
wasi: Option<Wasi>,
}

View File

@@ -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);
@@ -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,
};
@@ -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 {