-
Notifications
You must be signed in to change notification settings - Fork 26
/
lib.rs
74 lines (62 loc) · 1.79 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
use std::collections::HashMap;
use ipnetwork::IpNetwork;
pub mod api;
pub mod pty;
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(rename_all = "PascalCase")]
pub struct RunConfig {
pub image_config: Option<ImageConfig>,
pub exec_override: Option<Vec<String>>,
pub extra_env: Option<HashMap<String, String>>,
pub user_override: Option<String>,
pub cmd_override: Option<String>,
#[serde(rename = "IPConfigs")]
pub ip_configs: Option<Vec<IPConfig>>,
#[serde(default)]
pub tty: bool,
pub hostname: String,
pub mounts: Option<Vec<Mount>>,
pub root_device: Option<String>,
pub etc_resolv: Option<EtcResolv>,
pub etc_hosts: Option<Vec<EtcHost>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct ImageConfig {
pub entrypoint: Option<Vec<String>>,
pub cmd: Option<Vec<String>>,
pub env: Option<Vec<String>>,
pub working_dir: Option<String>,
pub user: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct IPConfig {
pub gateway: IpNetwork,
#[serde(rename = "IP")]
pub ip: IpNetwork,
pub mask: u8,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct Mount {
pub mount_path: String,
pub device_path: String,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct EtcHost {
pub host: String,
#[serde(rename = "IP")]
pub ip: String,
pub desc: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct EtcResolv {
pub nameservers: Vec<String>,
}