Skip to content

Commit

Permalink
Merge pull request #127 from fussybeaver/ND-info-route
Browse files Browse the repository at this point in the history
Info API
  • Loading branch information
Niel Drummond authored Nov 19, 2020
2 parents b0c98c9 + eee1baa commit 0dcfd24
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
test_ssl:
docker:
- image: docker:19.03.13
- image: docker:20.10.0-rc1
steps:
- checkout
- setup_remote_docker
Expand All @@ -15,7 +15,7 @@ jobs:
- run: docker run -ti -e DOCKER_CERT_PATH=/certs -e DOCKER_HOST='tcp://test.example.com:2376' --volumes-from certs --rm --link test-docker-daemon:docker bollard cargo test --features test_ssl -- --test test_version_ssl
test_http:
docker:
- image: docker:19.03.13
- image: docker:20.10.0-rc1
steps:
- checkout
- setup_remote_docker
Expand All @@ -24,31 +24,31 @@ jobs:
- run: docker run -ti -e DOCKER_HOST='tcp://test.example.com:2375' --rm --link test-docker-daemon:docker bollard cargo test --features test_http -- --test test_version_http
test_unix:
docker:
- image: docker:19.03.13
- image: docker:20.10.0-rc1
steps:
- checkout
- setup_remote_docker
- run: docker build -t bollard .
- run: dockerfiles/bin/run_integration_tests.sh
test_doc:
docker:
- image: docker:19.03.13
- image: docker:20.10.0-rc1
steps:
- checkout
- setup_remote_docker
- run: docker build -t bollard .
- run: docker run -ti --rm bollard cargo test --target x86_64-unknown-linux-gnu --doc
test_clippy:
docker:
- image: docker:19.03.13
- image: docker:20.10.0-rc1
steps:
- checkout
- setup_remote_docker
- run: docker build -t bollard .
- run: docker run -ti --rm bollard bash -c "rustup component add clippy && cargo clippy"
test_audit:
docker:
- image: docker:19.03.13
- image: docker:20.10.0-rc1
steps:
- checkout
- setup_remote_docker
Expand Down
28 changes: 28 additions & 0 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,34 @@ impl Docker {
self.process_into_value(req).await
}

/// ---
///
/// # Info
///
/// Returns Docker client and server information that is running.
///
/// # Returns
///
/// - [Info](system/struct.Info.html), wrapped in a Future.
///
/// # Examples
///
/// ```rust
/// # use bollard::Docker;
/// # let docker = Docker::connect_with_http_defaults().unwrap();
/// docker.info();
/// ```
pub async fn info(&self) -> Result<SystemInfo, Error> {
let req = self.build_request(
"/info",
Builder::new().method(Method::GET),
None::<String>,
Ok(Body::empty()),
);

self.process_into_value(req).await
}

/// ---
///
/// # Ping
Expand Down
20 changes: 20 additions & 0 deletions tests/system_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ async fn events_until_forever_test(docker: Docker) -> Result<(), Error> {

Ok(())
}

async fn df_test(docker: Docker) -> Result<(), Error> {
create_image_hello_world(&docker).await?;

Expand All @@ -149,6 +150,20 @@ async fn df_test(docker: Docker) -> Result<(), Error> {
Ok(())
}

async fn info_test(docker: Docker) -> Result<(), Error> {

let res = &docker.info().await?;
let os_type = if cfg!(windows) {
"windows"
} else {
"linux"
};

assert_eq!(os_type, res.os_type.as_ref().unwrap());

Ok(())
}

#[test]
fn integration_test_events() {
connect_to_docker_and_run!(events_test);
Expand All @@ -164,3 +179,8 @@ fn integration_test_events_until_forever() {
fn integration_test_df() {
connect_to_docker_and_run!(df_test);
}

#[test]
fn integration_test_info() {
connect_to_docker_and_run!(info_test);
}

0 comments on commit 0dcfd24

Please sign in to comment.