Class: DockerEngineRuby::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- DockerEngineRuby::Client
- Defined in:
- lib/docker_engine_ruby/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0- DEFAULT_TLS_VERIFY_PEER =
Whether to verify server TLS certificate chain.
true- ENVIRONMENTS =
rubocop:disable Style/MutableConstant
{production: "http://localhost:2375", production_tls: "https://localhost:2376"}
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS, Internal::Transport::BaseClient::REDIRECT_STATUSES
Instance Attribute Summary collapse
- #auth ⇒ DockerEngineRuby::Resources::Auth readonly
- #configs ⇒ DockerEngineRuby::Resources::Configs readonly
- #containers ⇒ DockerEngineRuby::Resources::Containers readonly
- #distribution ⇒ DockerEngineRuby::Resources::Distribution readonly
- #exec_ ⇒ DockerEngineRuby::Resources::Exec readonly
- #images ⇒ DockerEngineRuby::Resources::Images readonly
- #networks ⇒ DockerEngineRuby::Resources::Networks readonly
- #nodes ⇒ DockerEngineRuby::Resources::Nodes readonly
- #plugins ⇒ DockerEngineRuby::Resources::Plugins readonly
- #secrets ⇒ DockerEngineRuby::Resources::Secrets readonly
- #services ⇒ DockerEngineRuby::Resources::Services readonly
- #swarm ⇒ DockerEngineRuby::Resources::Swarm readonly
- #system_ ⇒ DockerEngineRuby::Resources::System readonly
- #tasks ⇒ DockerEngineRuby::Resources::Tasks readonly
-
#tls_ca_cert_path ⇒ String?
readonly
Path to the trusted CA certificate file (PEM) used to verify the Docker daemon certificate.
-
#tls_client_cert_path ⇒ String?
readonly
Path to the client TLS certificate file (PEM).
-
#tls_client_key_path ⇒ String?
readonly
Path to the client TLS private key file (PEM).
- #volumes ⇒ DockerEngineRuby::Resources::Volumes readonly
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(tls_ca_cert_path: ENV["DOCKER_TLS_CA_CERT_PATH"], tls_client_cert_path: ENV["DOCKER_TLS_CLIENT_CERT_PATH"], tls_client_key_path: ENV["DOCKER_TLS_CLIENT_KEY_PATH"], environment: nil, base_url: ENV["DOCKER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY, tls_verify_peer: self.class::DEFAULT_TLS_VERIFY_PEER) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, redirect_status?, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(tls_ca_cert_path: ENV["DOCKER_TLS_CA_CERT_PATH"], tls_client_cert_path: ENV["DOCKER_TLS_CLIENT_CERT_PATH"], tls_client_key_path: ENV["DOCKER_TLS_CLIENT_KEY_PATH"], environment: nil, base_url: ENV["DOCKER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY, tls_verify_peer: self.class::DEFAULT_TLS_VERIFY_PEER) ⇒ Client
Creates and returns a new client for interacting with the API.
certificate. Defaults to ‘ENV`
‘ENV`
‘ENV`
Each environment maps to a different base URL:
-
productioncorresponds tohttp://localhost:2375 -
production_tlscorresponds tohttps://localhost:2376
‘“api.example.com/v2/”`. Defaults to `ENV`
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/docker_engine_ruby/client.rb', line 114 def initialize( tls_ca_cert_path: ENV["DOCKER_TLS_CA_CERT_PATH"], tls_client_cert_path: ENV["DOCKER_TLS_CLIENT_CERT_PATH"], tls_client_key_path: ENV["DOCKER_TLS_CLIENT_KEY_PATH"], environment: nil, base_url: ENV["DOCKER_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY, tls_verify_peer: self.class::DEFAULT_TLS_VERIFY_PEER ) base_url ||= DockerEngineRuby::Client::ENVIRONMENTS.fetch(environment&.to_sym || :production) do = "environment must be one of " \ "#{DockerEngineRuby::Client::ENVIRONMENTS.keys}, got #{environment}" raise ArgumentError.new() end @tls_ca_cert_path = tls_ca_cert_path&.to_s @tls_client_cert_path = tls_client_cert_path&.to_s @tls_client_key_path = tls_client_key_path&.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, tls_verify_peer: tls_verify_peer, tls_ca_cert_path: @tls_ca_cert_path, tls_client_cert_path: @tls_client_cert_path, tls_client_key_path: @tls_client_key_path ) @auth = DockerEngineRuby::Resources::Auth.new(client: self) @system_ = DockerEngineRuby::Resources::System.new(client: self) @containers = DockerEngineRuby::Resources::Containers.new(client: self) @exec_ = DockerEngineRuby::Resources::Exec.new(client: self) @images = DockerEngineRuby::Resources::Images.new(client: self) @networks = DockerEngineRuby::Resources::Networks.new(client: self) @volumes = DockerEngineRuby::Resources::Volumes.new(client: self) @services = DockerEngineRuby::Resources::Services.new(client: self) @configs = DockerEngineRuby::Resources::Configs.new(client: self) @secrets = DockerEngineRuby::Resources::Secrets.new(client: self) @nodes = DockerEngineRuby::Resources::Nodes.new(client: self) @swarm = DockerEngineRuby::Resources::Swarm.new(client: self) @tasks = DockerEngineRuby::Resources::Tasks.new(client: self) @plugins = DockerEngineRuby::Resources::Plugins.new(client: self) @distribution = DockerEngineRuby::Resources::Distribution.new(client: self) end |
Instance Attribute Details
#auth ⇒ DockerEngineRuby::Resources::Auth (readonly)
40 41 42 |
# File 'lib/docker_engine_ruby/client.rb', line 40 def auth @auth end |
#configs ⇒ DockerEngineRuby::Resources::Configs (readonly)
64 65 66 |
# File 'lib/docker_engine_ruby/client.rb', line 64 def configs @configs end |
#containers ⇒ DockerEngineRuby::Resources::Containers (readonly)
46 47 48 |
# File 'lib/docker_engine_ruby/client.rb', line 46 def containers @containers end |
#distribution ⇒ DockerEngineRuby::Resources::Distribution (readonly)
82 83 84 |
# File 'lib/docker_engine_ruby/client.rb', line 82 def distribution @distribution end |
#exec_ ⇒ DockerEngineRuby::Resources::Exec (readonly)
49 50 51 |
# File 'lib/docker_engine_ruby/client.rb', line 49 def exec_ @exec_ end |
#images ⇒ DockerEngineRuby::Resources::Images (readonly)
52 53 54 |
# File 'lib/docker_engine_ruby/client.rb', line 52 def images @images end |
#networks ⇒ DockerEngineRuby::Resources::Networks (readonly)
55 56 57 |
# File 'lib/docker_engine_ruby/client.rb', line 55 def networks @networks end |
#nodes ⇒ DockerEngineRuby::Resources::Nodes (readonly)
70 71 72 |
# File 'lib/docker_engine_ruby/client.rb', line 70 def nodes @nodes end |
#plugins ⇒ DockerEngineRuby::Resources::Plugins (readonly)
79 80 81 |
# File 'lib/docker_engine_ruby/client.rb', line 79 def plugins @plugins end |
#secrets ⇒ DockerEngineRuby::Resources::Secrets (readonly)
67 68 69 |
# File 'lib/docker_engine_ruby/client.rb', line 67 def secrets @secrets end |
#services ⇒ DockerEngineRuby::Resources::Services (readonly)
61 62 63 |
# File 'lib/docker_engine_ruby/client.rb', line 61 def services @services end |
#swarm ⇒ DockerEngineRuby::Resources::Swarm (readonly)
73 74 75 |
# File 'lib/docker_engine_ruby/client.rb', line 73 def swarm @swarm end |
#system_ ⇒ DockerEngineRuby::Resources::System (readonly)
43 44 45 |
# File 'lib/docker_engine_ruby/client.rb', line 43 def system_ @system_ end |
#tasks ⇒ DockerEngineRuby::Resources::Tasks (readonly)
76 77 78 |
# File 'lib/docker_engine_ruby/client.rb', line 76 def tasks @tasks end |
#tls_ca_cert_path ⇒ String? (readonly)
Path to the trusted CA certificate file (PEM) used to verify the Docker daemon certificate.
29 30 31 |
# File 'lib/docker_engine_ruby/client.rb', line 29 def tls_ca_cert_path @tls_ca_cert_path end |
#tls_client_cert_path ⇒ String? (readonly)
Path to the client TLS certificate file (PEM).
33 34 35 |
# File 'lib/docker_engine_ruby/client.rb', line 33 def tls_client_cert_path @tls_client_cert_path end |
#tls_client_key_path ⇒ String? (readonly)
Path to the client TLS private key file (PEM).
37 38 39 |
# File 'lib/docker_engine_ruby/client.rb', line 37 def tls_client_key_path @tls_client_key_path end |
#volumes ⇒ DockerEngineRuby::Resources::Volumes (readonly)
58 59 60 |
# File 'lib/docker_engine_ruby/client.rb', line 58 def volumes @volumes end |