Module: Docker::API::Transport
- Defined in:
- lib/docker/api/transport.rb,
lib/docker/api/transport/tcp.rb,
lib/docker/api/transport/tls.rb,
lib/docker/api/transport/base.rb,
lib/docker/api/transport/fake.rb,
lib/docker/api/transport/unix.rb,
lib/docker/api/transport/named_pipe.rb
Overview
Transports know how to reach a daemon, and nothing else.
Every transport answers Base#connect with a connected IO. That single responsibility is what lets the same connection code drive a unix socket in development, TLS in CI and a Windows named pipe on a laptop.
Defined Under Namespace
Classes: Base, Fake, NamedPipe, Tcp, Tls, Unix
Class Method Summary collapse
-
.for(url:, tls: nil, open_timeout: 10) ⇒ Docker::API::Transport::Base
Build the transport a Docker host URL calls for.
Class Method Details
.for(url:, tls: nil, open_timeout: 10) ⇒ Docker::API::Transport::Base
Build the transport a Docker host URL calls for.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/docker/api/transport.rb', line 28 def self.for(url:, tls: nil, open_timeout: 10) scheme, rest = split(url.to_s) tls = nil if tls.respond_to?(:empty?) && tls.empty? case scheme when "unix" Unix.new(path: rest) when "npipe" NamedPipe.new(path: rest) when "https" tcp_transport(rest, tls || {}, open_timeout, secure: true) when "tcp", "http" tcp_transport(rest, tls, open_timeout, secure: !tls.nil?) else raise ConnectionError.new( "cannot reach a Docker daemon over '#{scheme}' (from #{url.inspect}); " \ "expected one of unix, tcp, http, https or npipe" ) end end |