use std::iter::once; use std::path::PathBuf; use buildkit_proto::pb::Meta; #[derive(Debug, Clone)] pub(crate) struct Context { pub name: String, pub args: Vec, pub env: Vec, pub cwd: PathBuf, pub user: String, } impl Context { pub fn new(name: S) -> Self where S: Into, { Self { name: name.into(), cwd: PathBuf::from("/"), user: "root".into(), args: vec![], env: vec![], } } } impl Into for Context { fn into(self) -> Meta { Meta { args: { once(self.name.clone()) .chain(self.args.iter().cloned()) .collect() }, env: self.env, cwd: self.cwd.to_string_lossy().into(), user: self.user, ..Default::default() } } }