Skip to content

Commit 1a2f020

Browse files
committed
feat: Add exec-check-success
1 parent 12e0902 commit 1a2f020

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

  • activity/fly-http

activity/fly-http/impl/src/machine.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,26 @@ impl Guest for Component {
391391
})()
392392
.map_err(|err| err.to_string())
393393
}
394+
395+
fn exec_check_success(
396+
app_name: String,
397+
machine_id: String,
398+
command: Vec<String>,
399+
) -> Result<ExecResponse, String> {
400+
(|| {
401+
let app_name = AppName::new(app_name)?;
402+
let machine_id = MachineId::new(machine_id)?;
403+
block_on(async {
404+
let resp = exec(app_name, machine_id, command).await?;
405+
if resp.exit_code == Some(0) {
406+
Ok(resp)
407+
} else {
408+
bail!("non-successful exit status - {resp:?}")
409+
}
410+
})
411+
})()
412+
.map_err(|err| err.to_string())
413+
}
394414
}
395415

396416
#[cfg(test)]

activity/fly-http/wit/obelisk-flyio_activity-fly-http@1.0.0-beta/fly.wit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ interface machines {
215215
delete: func(app-name: string, machine-id: machine-id, force: bool) -> result<_, string>;
216216

217217
exec: func(app-name: string, machine-id: machine-id, command: list<string>) -> result<exec-response, string>;
218+
219+
exec-check-success: func(app-name: string, machine-id: machine-id, command: list<string>) -> result<exec-response, string>;
218220
}
219221

220222
/// [App Secrets API](https://docs.machines.dev/#tag/secrets/get/apps/{app_name}/secrets)

0 commit comments

Comments
 (0)