file argument binding #35

Merged
JakeHillion merged 1 commits from bind-file-arguments into main 2022-05-17 12:33:05 +01:00
Showing only changes of commit 0c77cd47f7 - Show all commits

View File

@ -4,7 +4,7 @@ mod args;
use args::PreparedArgs; use args::PreparedArgs;
use crate::specification::{Entrypoint, Environment, Specification, Trigger}; use crate::specification::{Arg, Entrypoint, Environment, Specification, Trigger};
use crate::void::VoidBuilder; use crate::void::VoidBuilder;
use crate::{Error, Result}; use crate::{Error, Result};
use crate::{PipePair, SocketPair}; use crate::{PipePair, SocketPair};
@ -100,7 +100,7 @@ impl<'a> Spawner<'a> {
Trigger::Pipe(s) => { Trigger::Pipe(s) => {
let mut builder = VoidBuilder::new(); let mut builder = VoidBuilder::new();
self.mount_entrypoint(&mut builder, self.binary)?; self.mount_entrypoint(&mut builder, self.binary)?;
self.forward_mounts(&mut builder, &entrypoint.environment); self.forward_mounts(&mut builder, &entrypoint.environment, &entrypoint.args);
let pipe = self.pipes.get_mut(s).unwrap().take_read()?; let pipe = self.pipes.get_mut(s).unwrap().take_read()?;
builder.keep_fd(&pipe); builder.keep_fd(&pipe);
@ -124,7 +124,7 @@ impl<'a> Spawner<'a> {
Trigger::FileSocket(s) => { Trigger::FileSocket(s) => {
let mut builder = VoidBuilder::new(); let mut builder = VoidBuilder::new();
self.mount_entrypoint(&mut builder, self.binary)?; self.mount_entrypoint(&mut builder, self.binary)?;
self.forward_mounts(&mut builder, &entrypoint.environment); self.forward_mounts(&mut builder, &entrypoint.environment, &entrypoint.args);
let socket = self.sockets.get_mut(s).unwrap().take_read()?; let socket = self.sockets.get_mut(s).unwrap().take_read()?;
builder.keep_fd(&socket); builder.keep_fd(&socket);
@ -288,6 +288,7 @@ impl<'a> Spawner<'a> {
&self, &self,
builder: &mut VoidBuilder, builder: &mut VoidBuilder,
environment: impl IntoIterator<Item = &'b Environment>, environment: impl IntoIterator<Item = &'b Environment>,
arguments: impl IntoIterator<Item = &'b Arg>,
) { ) {
for env in environment { for env in environment {
if let Environment::Filesystem { if let Environment::Filesystem {
@ -298,6 +299,12 @@ impl<'a> Spawner<'a> {
builder.mount(host_path, host_path); builder.mount(host_path, host_path);
} }
} }
for arg in arguments {
if let Arg::File(host_path) = arg {
builder.mount(host_path, host_path);
}
}
} }
fn prepare_env<'b>( fn prepare_env<'b>(