buildkit_rs_llb/exec/
mod.rs

1mod mount;
2
3/*
4type ExecOp struct {
5    proxyEnv    *ProxyEnv
6    root        Output
7    mounts      []*mount
8    base        State
9    constraints Constraints
10    isValidated bool
11    secrets     []SecretInfo
12    ssh         []SSHInfo
13}
14*/
15
16pub struct Exec {
17    // pub proxy_env: Option<ProxyEnv>,
18    pub context: Option<ExecContext>,
19    // pub mounts: Vec<mount::Mount>,
20    // pub base: Option<State>,
21    // pub constraints: Constraints,
22    // pub is_validated: bool,
23    // pub secrets: Vec<SecretInfo>,
24    // pub ssh: Vec<SSHInfo>,
25}
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}