Module: Docker::Swarm
- Defined in:
- lib/docker-swarm.rb,
lib/docker/swarm/version.rb
Defined Under Namespace
Classes: Connection, Network, Node, Service, Swarm, Task
Constant Summary collapse
- VERSION =
The version of this gem.
'1.2.9'
- API_VERSION =
The version of the compatible Docker remote API.
'1.24'
Class Method Summary collapse
-
.authenticate!(options = {}, connection = self.connection) ⇒ Object
Login to the Docker registry.
- .connection ⇒ Object
-
.creds ⇒ Object
Returns the value of attribute creds.
-
.creds=(value) ⇒ Object
Sets the attribute creds.
- .default_socket_url ⇒ Object
- .env_options ⇒ Object
- .env_url ⇒ Object
-
.info(connection = self.connection) ⇒ Object
Get more information about the Docker server.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.logger=(value) ⇒ Object
Sets the attribute logger.
- .options ⇒ Object
- .options=(new_options) ⇒ Object
-
.ping(connection = self.connection) ⇒ Object
Ping the Docker server.
- .reset! ⇒ Object
- .reset_connection! ⇒ Object
- .ssl_options ⇒ Object
- .url ⇒ Object
- .url=(new_url) ⇒ Object
-
.validate_version! ⇒ Object
When the correct version of Docker is installed, returns true.
-
.version(connection = self.connection) ⇒ Object
Get the version of Go, Docker, and optionally the Git commit.
Class Method Details
.authenticate!(options = {}, connection = self.connection) ⇒ Object
Login to the Docker registry.
116 117 118 119 120 121 122 123 |
# File 'lib/docker-swarm.rb', line 116 def authenticate!( = {}, connection = self.connection) creds = .to_json connection.post('/auth', {}, :body => creds) @creds = creds true rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError raise Docker::Error::AuthenticationError end |
.connection ⇒ Object
86 87 88 |
# File 'lib/docker-swarm.rb', line 86 def connection @connection ||= Connection.new(url, ) end |
.creds ⇒ Object
Returns the value of attribute creds.
23 24 25 |
# File 'lib/docker-swarm.rb', line 23 def creds @creds end |
.creds=(value) ⇒ Object
Sets the attribute creds
23 24 25 |
# File 'lib/docker-swarm.rb', line 23 def creds=(value) @creds = value end |
.default_socket_url ⇒ Object
32 33 34 |
# File 'lib/docker-swarm.rb', line 32 def default_socket_url 'unix:///var/run/docker.sock' end |
.env_options ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/docker-swarm.rb', line 40 def if cert_path = ENV['DOCKER_CERT_PATH'] { client_cert: File.join(cert_path, 'cert.pem'), client_key: File.join(cert_path, 'key.pem'), ssl_ca_file: File.join(cert_path, 'ca.pem'), scheme: 'https' }.merge() else {} end end |
.env_url ⇒ Object
36 37 38 |
# File 'lib/docker-swarm.rb', line 36 def env_url ENV['DOCKER_URL'] || ENV['DOCKER_HOST'] end |
.info(connection = self.connection) ⇒ Object
Get more information about the Docker server.
106 107 108 |
# File 'lib/docker-swarm.rb', line 106 def info(connection = self.connection) Util.parse_json(connection.get('/info')) end |
.logger ⇒ Object
Returns the value of attribute logger.
23 24 25 |
# File 'lib/docker-swarm.rb', line 23 def logger @logger end |
.logger=(value) ⇒ Object
Sets the attribute logger
23 24 25 |
# File 'lib/docker-swarm.rb', line 23 def logger=(value) @logger = value end |
.options ⇒ Object
72 73 74 |
# File 'lib/docker-swarm.rb', line 72 def @options ||= end |
.options=(new_options) ⇒ Object
81 82 83 84 |
# File 'lib/docker-swarm.rb', line 81 def () @options = .merge( || {}) reset_connection! end |
.ping(connection = self.connection) ⇒ Object
Ping the Docker server.
111 112 113 |
# File 'lib/docker-swarm.rb', line 111 def ping(connection = self.connection) connection.get('/_ping') end |
.reset! ⇒ Object
90 91 92 93 94 |
# File 'lib/docker-swarm.rb', line 90 def reset! @url = nil @options = nil reset_connection! end |
.reset_connection! ⇒ Object
96 97 98 |
# File 'lib/docker-swarm.rb', line 96 def reset_connection! @connection = nil end |
.ssl_options ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/docker-swarm.rb', line 53 def if ENV['DOCKER_SSL_VERIFY'] == 'false' { ssl_verify_peer: false } else {} end end |
.url ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/docker-swarm.rb', line 63 def url @url ||= env_url || default_socket_url # docker uses a default notation tcp:// which means tcp://localhost:2375 if @url == 'tcp://' @url = 'tcp://localhost:2375' end @url end |
.url=(new_url) ⇒ Object
76 77 78 79 |
# File 'lib/docker-swarm.rb', line 76 def url=(new_url) @url = new_url reset_connection! end |
.validate_version! ⇒ Object
When the correct version of Docker is installed, returns true. Otherwise, raises a VersionError.
127 128 129 130 131 132 |
# File 'lib/docker-swarm.rb', line 127 def validate_version! Docker.info true rescue Docker::Error::DockerError raise Docker::Error::VersionError, "Expected API Version: #{API_VERSION}" end |
.version(connection = self.connection) ⇒ Object
Get the version of Go, Docker, and optionally the Git commit.
101 102 103 |
# File 'lib/docker-swarm.rb', line 101 def version(connection = self.connection) Util.parse_json(connection.get('/version')) end |