buildkit_rs_llb/
state.rs

1/*
2
3type State struct {
4    out   Output
5    prev  *State
6    key   interface{}
7    value func(context.Context, *Constraints) (interface{}, error)
8    opts  []ConstraintsOpt
9    async *asyncState
10}
11 */
12
13/*
14keys
15
16    keyArgs         = contextKeyT("llb.exec.args")
17    keyDir          = contextKeyT("llb.exec.dir")
18    keyEnv          = contextKeyT("llb.exec.env")
19    keyExtraHost    = contextKeyT("llb.exec.extrahost")
20    keyHostname     = contextKeyT("llb.exec.hostname")
21    keyUlimit       = contextKeyT("llb.exec.ulimit")
22    keyCgroupParent = contextKeyT("llb.exec.cgroup.parent")
23    keyUser         = contextKeyT("llb.exec.user")
24
25    keyPlatform = contextKeyT("llb.platform")
26    keyNetwork  = contextKeyT("llb.network")
27    keySecurity = contextKeyT("llb.security")
28 */
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
31enum ContextKey {
32    /// `llb.exec.args`
33    Args,
34    /// `llb.exec.dir`
35    Dir,
36    /// `llb.exec.env`
37    Env,
38    /// `llb.exec.extrahost`
39    ExtraHost,
40    /// `llb.exec.hostname`
41    Hostname,
42    /// `llb.exec.ulimit`
43    Ulimit,
44    /// `llb.exec.cgroup.parent`
45    CgroupParent,
46    /// `llb.exec.user`
47    User,
48
49    /// `llb.platform`
50    Platform,
51    /// `llb.network`
52    Network,
53    /// `llb.security`
54    Security,
55}
56
57impl ContextKey {
58    pub fn as_str(&self) -> &str {
59        match self {
60            ContextKey::Args => "llb.exec.args",
61            ContextKey::Dir => "llb.exec.dir",
62            ContextKey::Env => "llb.exec.env",
63            ContextKey::ExtraHost => "llb.exec.extrahost",
64            ContextKey::Hostname => "llb.exec.hostname",
65            ContextKey::Ulimit => "llb.exec.ulimit",
66            ContextKey::CgroupParent => "llb.exec.cgroup.parent",
67            ContextKey::User => "llb.exec.user",
68            ContextKey::Platform => "llb.platform",
69            ContextKey::Network => "llb.network",
70            ContextKey::Security => "llb.security",
71        }
72    }
73}
74
75impl std::fmt::Display for ContextKey {
76    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
77        write!(f, "{}", self.as_str())
78    }
79}
80
81pub fn configure_dir(state: State, dir: String) -> State {
82    state
83}
84
85pub struct State {
86    // out: Output,
87    prev: Option<Box<State>>,
88    // key: Option<Box<dyn Any>>,
89    // value: Option<Box<dyn FnOnce(&mut Context, &mut Constraints) -> Result<Box<dyn Any>, Error>>>,
90    // opts: Vec<ConstraintsOpt>,
91    // async: Option<AsyncState>,
92}
93
94impl State {}