diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-07-10 13:20:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-10 13:20:47 +0200 |
commit | be2c402fafe80da37bb37a8d61db35b41bf63192 (patch) | |
tree | 2865e6a53a316fd65c4f8ca0331820c8ca421969 | |
parent | 7aa868fc3dc13445bdf3452146d3f7a7799d2da2 (diff) | |
parent | 5467fd3486b19d9638f29b8801e3db4a1dadfb96 (diff) |
Merge pull request #304 from matthiasbeyer/container-details
Container details
-rw-r--r-- | src/container.rs | 179 | ||||
-rw-r--r-- | src/image.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 2 |
3 files changed, 157 insertions, 30 deletions
diff --git a/src/container.rs b/src/container.rs index ad26238..60f7d61 100644 --- a/src/container.rs +++ b/src/container.rs @@ -19,7 +19,7 @@ use crate::{ docker::Docker, errors::{Error, Result}, exec::{Exec, ExecContainerOptions}, - image::Config, + image::ContainerConfig, network::NetworkSettings, transport::Payload, tty::{self, Multiplexer as TtyMultiPlexer}, @@ -1194,37 +1194,47 @@ pub struct ContainerInfo { pub ports: Vec<Port>, pub state: String, pub status: String, - pub size_rw: Option<u64>, - pub size_root_fs: Option<u64>, + pub size_rw: Option<i64>, + pub size_root_fs: Option<i64>, } #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ContainerDetails { - pub app_armor_profile: String, - pub args: Vec<String>, - pub config: Config, + pub id: String, #[cfg(feature = "chrono")] pub created: DateTime<Utc>, #[cfg(not(feature = "chrono"))] pub created: String, - pub driver: String, - // pub ExecIDs: ?? - pub host_config: HostConfig, + pub path: String, + pub args: Vec<String>, + pub state: State, + pub image: String, + pub resolv_conf_path: String, pub hostname_path: String, pub hosts_path: String, pub log_path: String, - pub id: String, - pub image: String, - pub mount_label: String, pub name: String, - pub network_settings: NetworkSettings, - pub path: String, + pub restart_count: i64, + pub driver: String, + pub platform: String, + pub mount_label: String, pub process_label: String, - pub resolv_conf_path: String, - pub restart_count: u64, - pub state: State, + pub app_armor_profile: String, + #[serde(rename = "ExecIDs")] + pub exec_ids: Option<Vec<String>>, + pub host_config: HostConfig, + pub graph_driver: GraphDriverData, pub mounts: Vec<Mount>, + pub config: ContainerConfig, + pub network_settings: NetworkSettings, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GraphDriverData { + pub name: String, + pub data: HashMap<String, String>, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -1262,22 +1272,139 @@ pub struct State { #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct HostConfig { + pub cpu_shares: Option<i64>, + pub memory: Option<i64>, pub cgroup_parent: Option<String>, - #[serde(rename = "ContainerIDFile")] - pub container_id_file: String, - pub cpu_shares: Option<u64>, + pub blkio_weight_device: Option<Vec<ThrottleDevice>>, + pub blkio_device_read_bps: Option<Vec<ThrottleDevice>>, + pub blkio_device_write_bps: Option<Vec<ThrottleDevice>>, + #[serde(rename = "BlkioDeviceReadIOps")] + pub blkio_device_read_iops: Option<Vec<ThrottleDevice>>, + #[serde(rename = "BlkioDeviceWriteIOps")] + pub blkio_device_write_iops: Option<Vec<ThrottleDevice>>, + pub cpu_period: Option<i64>, + pub cpu_quota: Option<i64>, + pub cpu_realtime_period: Option<i64>, + pub cpu_realtime_runtime: Option<i64>, pub cpuset_cpus: Option<String>, - pub memory: Option<u64>, + pub cpuset_mems: Option<String>, + pub devices: Option<Vec<DeviceMapping>>, + pub device_cgroup_rules: Option<String>, + pub device_requests: Option<Vec<DeviceRequest>>, + #[serde(rename = "KernelMemoryTCP")] + pub kernel_memory_tcp: i64, + pub memory_reservation: Option<i64>, pub memory_swap: Option<i64>, + pub memory_swappiness: Option<i64>, + #[serde(rename = "NanoCPUs")] + pub nano_cpus: Option<i64>, + pub oom_kill_disable: bool, + pub init: Option<bool>, + pub pids_limit: Option<i64>, + pub ulimits: Option<Vec<Ulimit>>, + pub cpu_count: i64, + pub cpu_percent: i64, + #[serde(rename = "IOMaximumIOps")] + pub io_maximum_iops: u64, + #[serde(rename = "IOMaximumBandwith")] + pub io_maximum_bandwith: Option<u64>, + pub binds: Option<Vec<String>>, + #[serde(rename = "ContainerIDFile")] + pub container_id_file: String, + pub log_config: LogConfig, pub network_mode: String, + pub port_bindings: Option<PortMap>, + pub restart_policy: RestartPolicy, + pub auto_remove: bool, + pub volume_driver: String, + pub volumes_from: Option<Vec<String>>, + pub mounts: Option<Vec<Mount>>, + pub cap_add: Option<Vec<String>>, + pub cap_drop: Option<Vec<String>>, + pub dns: Option<Vec<String>>, + pub dns_options: Option<Vec<String>>, + pub dns_search: Option<Vec<String>>, + pub extra_hosts: Option<Vec<String>>, + pub group_add: Option<Vec<String>>, + pub ipc_mode: String, + pub cgroup: String, + pub links: Option<Vec<String>>, + pub oom_score_adj: i64, pub pid_mode: Option<String>, - pub port_bindings: Option<HashMap<String, Vec<HashMap<String, String>>>>, pub privileged: bool, pub publish_all_ports: bool, - pub readonly_rootfs: Option<bool>, /* pub RestartPolicy: ??? - * pub SecurityOpt: Option<???>, - * pub Ulimits: Option<???> - * pub VolumesFrom: Option<??/> */ + pub readonly_rootfs: Option<bool>, + pub security_opt: Option<Vec<String>>, + pub storage_opt: Option<HashMap<String, String>>, + pub tmpfs: Option<HashMap<String, String>>, + #[serde(rename = "UTSMode")] + pub uts_mode: String, + pub userns_mode: String, + pub shm_size: u64, + pub sysctls: Option<HashMap<String, String>>, + pub runtime: String, + pub console_size: Option<Vec<u64>>, + pub isolation: String, + pub masked_paths: Option<Vec<String>>, + pub readonly_paths: Option<Vec<String>>, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct ThrottleDevice { + pub path: String, + pub rate: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct RestartPolicy { + pub name: String, + pub maximum_retry_count: u64, +} + +pub type PortMap = HashMap<String, Option<Vec<PortBinding>>>; + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct PortBinding { + pub host_ip: String, + pub host_port: String, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct LogConfig { + #[serde(rename = "Type")] + pub type_: String, + #[serde(rename = "Config")] + pub config: HashMap<String, String>, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct Ulimit { + pub name: String, + pub soft: u64, + pub hard: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct DeviceMapping { + pub path_on_host: Option<String>, + pub path_in_container: Option<String>, + pub cgroup_permissions: Option<String>, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct DeviceRequest { + pub driver: String, + pub count: u64, + #[serde(rename = "DeviceIDs")] + pub device_ids: Vec<String>, + pub capabilities: Vec<String>, + pub options: Option<serde_json::Value>, } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/src/image.rs b/src/image.rs index f19dbad..6df8cb7 100644 --- a/src/image.rs +++ b/src/image.rs @@ -799,7 +799,7 @@ pub struct ImageDetails { pub architecture: String, pub author: String, pub comment: String, - pub config: Config, + pub config: ContainerConfig, #[cfg(feature = "chrono")] pub created: DateTime<Utc>, #[cfg(not(feature = "chrono"))] @@ -816,7 +816,7 @@ pub struct ImageDetails { #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct Config { +pub struct ContainerConfig { pub attach_stderr: bool, pub attach_stdin: bool, pub attach_stdout: bool, @@ -838,7 +838,7 @@ pub struct Config { pub working_dir: String, } -impl Config { +impl ContainerConfig { pub fn env(&self) -> HashMap<String, String> { let mut map = HashMap::new(); if let Some(ref vars) = self.env { @@ -119,7 +119,7 @@ reexport! { docker::{Version, Info, Event, Actor}; exec::{ExecDetails, ProcessConfig}; image::{ - SearchResult, ImageInfo as Image, ImageDetails, Config, History, Status, + SearchResult, ImageInfo as Image, ImageDetails, ContainerConfig, History, Status, }; network::{ NetworkSettings, NetworkEntry, Ipam, NetworkDetails, |