vm: enable optional input and output data

This commit is contained in:
Ryan Heywood 2025-05-12 16:50:08 -04:00
parent bc41781df0
commit 7dee69f35b
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 8 additions and 6 deletions

View File

@ -583,7 +583,7 @@ impl VirtualMachine {
"path": command, "path": command,
"arg": args, "arg": args,
"capture-output": true, "capture-output": true,
"input-data": input, "input-data": input.unwrap_or_default(),
}); });
let bar = spinner(format!("Running: {command:?} {args:?}")); let bar = spinner(format!("Running: {command:?} {args:?}"));
@ -609,11 +609,13 @@ impl VirtualMachine {
} }
bar.finish_and_clear(); bar.finish_and_clear();
let out_data = status let out_data = if let Some(out_data) = status.get("out-data") {
.get("out-data") out_data
.ok_or(eyre::eyre!("response had no out-data"))? .as_str()
.as_str() .ok_or(eyre::eyre!("response['out-data'] is not string"))?
.ok_or(eyre::eyre!("response['out-data'] is not string"))?; } else {
""
};
let parsed_data = BASE64_STANDARD let parsed_data = BASE64_STANDARD
.decode(out_data) .decode(out_data)
.context("response output was not base64")?; .context("response output was not base64")?;