diff options
author | Felix Krull <f_krull@gmx.de> | 2018-09-08 01:39:08 +0200 |
---|---|---|
committer | Felix Krull <f_krull@gmx.de> | 2018-09-08 01:39:08 +0200 |
commit | 6e8a2179cfbfd447453475b9de4984a2c93ce377 (patch) | |
tree | 044e225c138192e21230059372b6f14e2f2ac576 /src | |
parent | 061853516312406019ae4344ba662480ba5a5988 (diff) |
Make Unix socket support optional
By making Unix sockets optional, hyperlocal becomes optional as well,
which means shiplift builds on Windows.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 9 | ||||
-rw-r--r-- | src/transport.rs | 6 |
2 files changed, 11 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", diff --git a/src/transport.rs b/src/transport.rs index c7c5d1e..ffa040d 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -12,7 +12,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 +30,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 +38,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 +83,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 { |