From 95beb6f2aaf36d38ca1dc3abb7544fb878c45ca0 Mon Sep 17 00:00:00 2001 From: Abc Xyz Date: Mon, 22 Feb 2021 02:12:21 +0300 Subject: Add missing fields to `ImageDetails` and `History` (#264) * Add missing fields to `ImageDetails` and `History` * Make some fields in `ContainerConfig` required --- CHANGELOG.md | 5 +++ src/rep.rs | 103 ++++++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 82 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 631142d..c53c86d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # 0.8.0 * `ContainerOptionsBuilder::entrypoint` now correctly takes an `IntoIterator>` instead of `&str` [#269](https://github.com/softprops/shiplift/pull/269) +* make `config` field of `ImageDetails` optional [#264](https://github.com/softprops/shiplift/pull/264) +* add `container`, `container_config`, `os_version`, `graph_driver`, `root_fs`, `metadata` fields to `ImageDetails` [#264](https://github.com/softprops/shiplift/pull/264) +* rename `shiplift::rep::Config` to `shiplift::rep::ContainerConfig` [#264](https://github.com/softprops/shiplift/pull/264) +* add missing fields ([API version 1.41](https://docs.docker.com/engine/api/v1.41/#operation/ImageInspect)) to `ContainerConfig` [#264](https://github.com/softprops/shiplift/pull/264) +* add missing fields ([API version 1.41](https://docs.docker.com/engine/api/v1.41/#operation/ImageHistory)) to `History` [#264](https://github.com/softprops/shiplift/pull/264) # 0.7.0 diff --git a/src/rep.rs b/src/rep.rs index 62b248a..d12faf3 100644 --- a/src/rep.rs +++ b/src/rep.rs @@ -33,22 +33,29 @@ pub struct Image { #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ImageDetails { - pub architecture: String, - pub author: String, + pub id: String, + pub repo_tags: Option>, + pub repo_digests: Option>, + pub parent: String, pub comment: String, - pub config: Config, #[cfg(feature = "chrono")] pub created: DateTime, #[cfg(not(feature = "chrono"))] pub created: String, + pub container: String, + pub container_config: Option, pub docker_version: String, - pub id: String, + pub author: String, + pub config: Option, + pub architecture: String, pub os: String, - pub parent: String, - pub repo_tags: Option>, - pub repo_digests: Option>, - pub size: u64, - pub virtual_size: u64, + pub os_version: Option, + pub size: i64, + pub virtual_size: i64, + pub graph_driver: GraphDriverData, + #[serde(rename = "RootFS")] + pub root_fs: RootFS, + pub metadata: Metadata, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -78,7 +85,7 @@ pub struct Container { pub struct ContainerDetails { pub app_armor_profile: String, pub args: Vec, - pub config: Config, + pub config: ContainerConfig, #[cfg(feature = "chrono")] pub created: DateTime, #[cfg(not(feature = "chrono"))] @@ -194,29 +201,35 @@ pub struct HostConfig { #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] -pub struct Config { - pub attach_stderr: bool, +pub struct ContainerConfig { + pub hostname: String, + pub domainname: String, + pub user: String, pub attach_stdin: bool, pub attach_stdout: bool, - pub cmd: Option>, - pub domainname: String, - pub entrypoint: Option>, - pub env: Option>, + pub attach_stderr: bool, pub exposed_ports: Option>>, - pub hostname: String, - pub image: String, - pub labels: Option>, - // pub MacAddress: String, - pub on_build: Option>, - // pub NetworkDisabled: bool, + pub tty: bool, pub open_stdin: bool, pub stdin_once: bool, - pub tty: bool, - pub user: String, + pub env: Option>, + pub cmd: Option>, + pub healtcheck: Option, + pub args_escaped: Option, + pub image: String, + pub volumes: Option>>, pub working_dir: String, + pub entrypoint: Option>, + pub network_disabled: Option, + pub mac_address: Option, + pub on_build: Option>, + pub labels: Option>, + pub stop_signal: Option, + pub stop_timeout: Option, + pub shell: Option>, } -impl Config { +impl ContainerConfig { pub fn env(&self) -> HashMap { let mut map = HashMap::new(); if let Some(ref vars) = self.env { @@ -229,6 +242,41 @@ impl Config { } } +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct HealthConfig { + pub test: Option>, + pub interval: Option, + pub timeout: Option, + pub retries: Option, + pub start_period: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct GraphDriverData { + pub name: String, + pub data: HashMap, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct RootFS { + #[serde(rename = "Type")] + pub typ: String, + pub layers: Option>, + pub base_layer: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct Metadata { + #[cfg(feature = "chrono")] + pub last_tag_time: DateTime, + #[cfg(not(feature = "chrono"))] + pub last_tag_time: String, +} + #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Port { @@ -460,8 +508,11 @@ pub struct History { #[serde(deserialize_with = "datetime_from_unix_timestamp")] pub created: DateTime, #[cfg(not(feature = "chrono"))] - pub created: u64, + pub created: i64, pub created_by: String, + pub tags: Option>, + pub size: i64, + pub comment: String, } #[derive(Clone, Debug, Serialize, Deserialize)] -- cgit v1.2.3