Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
feat: make execution command configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Jul 4, 2022
1 parent f843a58 commit 486b722
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ struct Args {
#[clap(long, default_value_t = 15)]
timeout: u64,

/// Command to execute, normally path to `enarx` binary.
/// This command will be executed as: `<cmd> run --wasmcfgfile <path-to-config> <path-to-wasm>`
#[clap(long, default_value = "enarx")]
command: String,

/// OpenID Connect issuer URL.
#[clap(long)]
oidc_issuer: Url,
Expand All @@ -88,6 +93,7 @@ async fn main() -> anyhow::Result<()> {
addr,
jobs,
timeout,
command,
oidc_issuer: _,
oidc_client: _,
oidc_secret: _,
Expand Down Expand Up @@ -138,7 +144,7 @@ async fn main() -> anyhow::Result<()> {
.route("/:uuid/err", post(uuid_err_post))
.route(
"/",
get(root_get).post(move |mp| root_post(mp, timeout, jobs)),
get(root_get).post(move |mp| root_post(mp, command, timeout, jobs)),
)
.layer(TraceLayer::new_for_http());

Expand All @@ -152,6 +158,7 @@ async fn root_get() -> Html<&'static str> {

async fn root_post(
mut multipart: Multipart,
command: String,
timeout: u64,
jobs: usize,
) -> Result<impl IntoResponse, StatusCode> {
Expand Down Expand Up @@ -228,7 +235,7 @@ async fn root_post(
let wasm = wasm.ok_or(StatusCode::BAD_REQUEST)?;
let toml = toml.ok_or(StatusCode::BAD_REQUEST)?;
let uuid = Uuid::new_v4();
let exec = Command::new("enarx")
let exec = Command::new(command)
.arg("run")
.arg("--wasmcfgfile")
.arg(toml.path())
Expand Down

0 comments on commit 486b722

Please sign in to comment.