diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 9 | ||||
-rw-r--r-- | src/rep.rs | 1 | ||||
-rw-r--r-- | src/transport.rs | 8 |
3 files changed, 14 insertions, 4 deletions
@@ -17,6 +17,7 @@ extern crate log; extern crate hyper; extern crate hyper_openssl; +#[cfg(feature = "unix-socket")] extern crate hyperlocal; extern crate flate2; extern crate jed; @@ -49,7 +50,6 @@ use hyper::header::ContentType; use hyper::method::Method; use hyper::net::HttpsConnector; use hyper_openssl::OpensslClient; -use hyperlocal::UnixSocketConnector; use openssl::ssl::{SslConnectorBuilder, SslMethod}; use openssl::x509::X509_FILETYPE_PEM; use rep::{Change, Container as ContainerRep, ContainerCreateInfo, @@ -641,14 +641,19 @@ impl Docker { /// constructs a new Docker instance for docker host listening at the given host url pub fn host(host: Url) -> Docker { match host.scheme() { + #[cfg(feature = "unix-socket")] "unix" => { Docker { transport: Transport::Unix { - client: Client::with_connector(UnixSocketConnector), + client: Client::with_connector(hyperlocal::UnixSocketConnector), path: host.path().to_owned(), }, } } + + #[cfg(not(feature = "unix-socket"))] + "unix" => panic!("Unix socket support is disabled"), + _ => { let client = if let Some(ref certs) = env::var( "DOCKER_CERT_PATH", @@ -70,6 +70,7 @@ pub struct ContainerDetails { pub Id: String, pub Image: String, pub MountLabel: String, + pub Name: String, pub NetworkSettings: NetworkSettings, pub Path: String, pub ProcessLabel: String, diff --git a/src/transport.rs b/src/transport.rs index c7c5d1e..69c2eab 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -1,6 +1,8 @@ //! Transports for communicating with the docker daemon extern crate hyper; +#[cfg(feature = "unix-socket")] +extern crate hyperlocal; use self::hyper::buffer::BufReader; use self::hyper::header::ContentType; @@ -12,7 +14,6 @@ use hyper::client::response::Response; use hyper::header; use hyper::method::Method; use hyper::mime; -use hyperlocal::DomainUrl; use rustc_serialize::json; use std::fmt; use std::io::Read; @@ -31,6 +32,7 @@ pub enum Transport { /// A network tcp interface Tcp { client: Client, host: String }, /// A Unix domain socket + #[cfg(feature = "unix-socket")] Unix { client: Client, path: String }, } @@ -38,6 +40,7 @@ impl fmt::Debug for Transport { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Transport::Tcp { ref host, .. } => write!(f, "Tcp({})", host), + #[cfg(feature = "unix-socket")] Transport::Unix { ref path, .. } => write!(f, "Unix({})", path), } } @@ -82,10 +85,11 @@ impl Transport { ref client, ref host, } => client.request(method, &format!("{}{}", host, endpoint)[..]), + #[cfg(feature = "unix-socket")] Transport::Unix { ref client, ref path, - } => client.request(method, DomainUrl::new(&path, endpoint)), + } => client.request(method, hyperlocal::DomainUrl::new(&path, endpoint)), }.headers(headers); let embodied = match body { |