From 3580c29b349585ae7de500ccb510659e9caf1500 Mon Sep 17 00:00:00 2001 From: Colvin Wellborn <39858617+colvin@users.noreply.github.com> Date: Thu, 26 Dec 2019 22:15:06 -0500 Subject: Expand rep::Version (#212) * expand the fields of Version Expands `shiplift::rep::Version` to contain fields for the following elements of the `/version` API: - `min_api_version` (`MinAPIVersion`) - `os` (`Os`) - `arch` (`Arch`) - `kernel_version` (`KernelVersion`) - `build_time` (`BuildTime`) Adds a new example program to display version information. * order version fields according to api docs * remove min_api_version For backwards compat with older engines, remove the `min_api_version` field. It was apparently added in API version `1.25.0` (circa 2017). --- examples/version.rs | 13 +++++++++++++ src/rep.rs | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 examples/version.rs diff --git a/examples/version.rs b/examples/version.rs new file mode 100644 index 0000000..6125e56 --- /dev/null +++ b/examples/version.rs @@ -0,0 +1,13 @@ +use shiplift::Docker; +use tokio::prelude::Future; + +fn main() { + env_logger::init(); + let docker = Docker::new(); + let fut = docker + .version() + .map(|ver| println!("version -> {:#?}", ver)) + .map_err(|e| eprintln!("Error: {}", e)); + + tokio::run(fut); +} diff --git a/src/rep.rs b/src/rep.rs index 7a96367..67b1028 100644 --- a/src/rep.rs +++ b/src/rep.rs @@ -404,10 +404,17 @@ pub struct Top { #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Version { - pub api_version: String, pub version: String, + pub api_version: String, pub git_commit: String, pub go_version: String, + pub os: String, + pub arch: String, + pub kernel_version: String, + #[cfg(feature = "chrono")] + pub build_time: DateTime, + #[cfg(not(feature = "chrono"))] + pub build_time: String, } #[derive(Clone, Debug, Serialize, Deserialize)] -- cgit v1.2.3