buildkit_rs_llb/exec/
mod.rs1mod mount;
2
3pub struct Exec {
17 pub context: Option<ExecContext>,
19 }
26
27impl Exec {
28 pub const fn new() -> Self {
29 Self { context: None }
30 }
31
32 pub fn shlex(input: impl AsRef<str>) -> Self {
33 let args = shlex::Shlex::new(input.as_ref()).into_iter().collect();
34
35 Self {
36 context: Some(ExecContext::new(args)),
37 }
38 }
39}
40
41#[derive(Debug, Clone)]
42pub struct ExecContext {
43 pub args: Vec<String>,
44 pub env: Vec<String>,
45 pub cwd: String,
46 pub user: String,
47}
48
49impl ExecContext {
50 pub fn new(args: Vec<String>) -> Self {
51 Self {
52 args,
53 env: vec![],
54 cwd: "/".into(),
55 user: "root".into(),
56 }
57 }
58
59 pub fn with_args(mut self, args: Vec<String>) -> Self {
60 self.args = args;
61 self
62 }
63
64 pub fn with_env(mut self, env: Vec<String>) -> Self {
65 self.env = env;
66 self
67 }
68
69 pub fn with_cwd(mut self, cwd: String) -> Self {
70 self.cwd = cwd;
71 self
72 }
73
74 pub fn with_user(mut self, user: String) -> Self {
75 self.user = user;
76 self
77 }
78}