diff --git a/.circleci/config.yml b/.circleci/config.yml
index 832dca83..d75559c4 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -29,7 +29,23 @@ jobs:
- checkout
- setup_remote_docker
- run: docker build -t bollard .
- - run: dockerfiles/bin/run_integration_tests.sh
+ - run: dockerfiles/bin/run_integration_tests.sh --tests
+ test_chrono:
+ docker:
+ - image: docker:20.10.16
+ steps:
+ - checkout
+ - setup_remote_docker
+ - run: docker build -t bollard .
+ - run: dockerfiles/bin/run_integration_tests.sh --features chrono --tests
+ test_time:
+ docker:
+ - image: docker:20.10.16
+ steps:
+ - checkout
+ - setup_remote_docker
+ - run: docker build -t bollard .
+ - run: dockerfiles/bin/run_integration_tests.sh --features time --tests
test_doc:
docker:
- image: docker:20.10.16
@@ -37,7 +53,7 @@ jobs:
- checkout
- setup_remote_docker
- run: docker build -t bollard .
- - run: docker run -ti --rm bollard cargo test --target x86_64-unknown-linux-gnu --doc
+ - run: docker run -ti --rm bollard cargo test --features time --target x86_64-unknown-linux-gnu --doc
test_clippy:
docker:
- image: docker:20.10.16
@@ -62,7 +78,7 @@ jobs:
- checkout
- setup_remote_docker
- run: docker build -t bollard .
- - run: docker run -ti --rm bollard bash -c "cargo fmt -- --check --verbose"
+ - run: docker run -ti --rm bollard bash -c "rustup component add rustfmt && cargo fmt -- --check --verbose"
workflows:
version: 2
test-image:
@@ -70,6 +86,8 @@ workflows:
- test_ssl
- test_http
- test_unix
+ - test_chrono
+ - test_time
- test_doc
- test_clippy
- test_audit
diff --git a/.dockerignore b/.dockerignore
index ee35a944..89e45807 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,7 +1,8 @@
.DS_Store
.git
Cargo.lock
-**/target
+/target
+/codegen/target/generated-sources/target
doc
main.rs
**/workspace
diff --git a/Cargo.toml b/Cargo.toml
index dd1ef330..d88892dc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ repository = "https://github.com/fussybeaver/bollard"
documentation = "https://docs.rs/bollard"
readme = "README.md"
keywords = ["docker"]
-edition = "2018"
+edition = "2021"
[features]
# Enable tests specifically for the http connector
@@ -21,12 +21,14 @@ test_macos = []
# Enable rustls / ssl
ssl = ["dirs-next", "hyper-rustls", "rustls", "rustls-native-certs", "rustls-pemfile", "webpki", "webpki-roots"]
ct_logs = ["ssl", "ct-logs"]
+chrono = ["dep:chrono", "bollard-stubs/chrono"]
+time = ["dep:time", "bollard-stubs/time"]
[dependencies]
base64 = "0.13"
-bollard-stubs = { version = "=1.42.0-rc.2" }
+bollard-stubs = { version = "=1.42.0-rc.3", default-features = false }
bytes = "1"
-chrono = { version = "0.4", features = ["serde"] }
+chrono = { version = "0.4", features = ["serde"], optional = true }
ct-logs = { version = "0.9.0", optional = true }
dirs-next = { version = "2.0", optional = true }
futures-core = "0.3"
@@ -46,6 +48,7 @@ serde_json = "1.0"
serde_urlencoded = "0.7"
tokio = { version = "1.7", features = ["time", "net", "io-util"] }
thiserror = "1.0"
+time = { version = "0.3", features = ["formatting", "parsing"], optional = true }
tokio-util = { version = "0.7", features = ["codec"] }
url = "2.2"
webpki-roots = { version = "0.22", optional = true }
diff --git a/Dockerfile b/Dockerfile
index fd36eaec..88477aaf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,11 +1,7 @@
-FROM ekidd/rust-musl-builder:stable AS builder
+FROM rust:1.61.0-buster
-WORKDIR /tmp/bollard
+WORKDIR /usr/src/bollard
-COPY . ./
-
-RUN sudo chown -R rust:rust /tmp/bollard \
- && sudo groupadd --gid 999 docker \
- && sudo usermod -a -G docker rust
+COPY . .
RUN cargo build
diff --git a/appveyor.yml b/appveyor.yml
index 36d7cb4a..b7b23931 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -40,4 +40,4 @@ test_script:
- ps: Set-Item -path env:RUST_BACKTRACE -value 1
- ps: Set-Item -path env:RUST_LOG -value "hyper=trace,bollard=debug"
- ps: Set-Item -path env:REGISTRY_HTTP_ADDR -value localhost:5000
- - cargo test --verbose -- --nocapture --test-threads 1
+ - cargo test --verbose --tests -- --nocapture --test-threads 1
diff --git a/codegen/pom.xml b/codegen/pom.xml
index 6c73d3e2..c785764f 100644
--- a/codegen/pom.xml
+++ b/codegen/pom.xml
@@ -31,7 +31,7 @@
models.rs,lib.rs,Cargo.toml,config,README.md
bollard-stubs
- 1.42.0-rc.2
+ 1.42.0-rc.3
diff --git a/codegen/src/main/java/bollard/BollardCodegen.java b/codegen/src/main/java/bollard/BollardCodegen.java
index 9a526bb5..616623f1 100644
--- a/codegen/src/main/java/bollard/BollardCodegen.java
+++ b/codegen/src/main/java/bollard/BollardCodegen.java
@@ -22,6 +22,7 @@ public class BollardCodegen extends RustServerCodegen {
public BollardCodegen() {
super();
+ typeMapping.put("DateTime", "BollardDate");
}
// Declare custom additions to inline enums that are behaving differently
@@ -123,9 +124,10 @@ public Map postProcessAllModels(Map objs) {
} else if (prop.name.equals("_type")) {
prop.name = "typ";
}
- if (prop.dataFormat != null && prop.dataFormat.equals("dateTime")) {
+ if (prop.dataFormat != null && (prop.dataFormat.equals("dateTime") || prop.datatype.equals("BollardDate"))) {
// set DateTime format on properties where appropriate
- prop.datatype = "DateTime";
+ prop.vendorExtensions.put("x-rustgen-is-datetime", true);
+ prop.datatype = "BollardDate";
}
if (prop.isEnum) {
if (enumToString.contains(model.classname)) {
diff --git a/codegen/src/main/resources/bollard/Cargo.mustache b/codegen/src/main/resources/bollard/Cargo.mustache
index d71d9a1c..b4b49b58 100644
--- a/codegen/src/main/resources/bollard/Cargo.mustache
+++ b/codegen/src/main/resources/bollard/Cargo.mustache
@@ -4,10 +4,11 @@ version = "{{appVersion}}"
authors = [ "Bollard contributors" ]
description = "Stubs used for the Bollard rust async Docker client API"
license = "Apache-2.0"
-edition = "2018"
+edition = "2021"
[dependencies]
-chrono = { version = "0.4", features = ["serde"] }
+chrono = { version = "0.4", features = ["serde"], optional = true }
serde = { version = "1.0", features = ["derive"] }
+time = { version = "0.3", features = ["formatting", "parsing"], optional = true }
serde_with = "1.4"
diff --git a/codegen/src/main/resources/bollard/models.mustache b/codegen/src/main/resources/bollard/models.mustache
index 6a932c77..76f7d1ee 100644
--- a/codegen/src/main/resources/bollard/models.mustache
+++ b/codegen/src/main/resources/bollard/models.mustache
@@ -9,9 +9,6 @@ use std::collections::HashMap;
use std::default::Default;
use std::hash::Hash;
-use chrono::DateTime;
-use chrono::Utc;
-
fn deserialize_nonoptional_vec<'de, D: Deserializer<'de>, T: DeserializeOwned>(
d: D,
) -> Result, D::Error> {
@@ -24,6 +21,52 @@ fn deserialize_nonoptional_map<'de, D: Deserializer<'de>, T: DeserializeOwned>(
serde::Deserialize::deserialize(d).map(|x: Option<_>| x.unwrap_or(HashMap::new()))
}
+#[cfg(feature = "time")]
+pub type BollardDate = time::OffsetDateTime;
+#[cfg(feature = "chrono")]
+pub type BollardDate = chrono::DateTime;
+#[cfg(not(any(feature = "chrono", feature = "time")))]
+pub type BollardDate = String;
+
+#[cfg(feature = "time")]
+fn deserialize_timestamp<'de, D: Deserializer<'de>>(
+ d: D
+) -> Result