module Docker::Swarm
Constants
- API_VERSION
The version of the compatible
Docker
remote API.- VERSION
The version of the docker-api gem.
Attributes
Public Class Methods
Login to the Docker
registry.
# File lib/docker-swarm.rb, line 122 def authenticate!(options = {}, connection = self.connection) creds = options.to_json connection.post('/auth', {}, :body => creds) @creds = creds true rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError raise Docker::Error::AuthenticationError end
# File lib/docker-swarm.rb, line 92 def connection @connection ||= Connection.new(url, options) end
require 'docker/swarm/node' require 'docker/swarm/service' require 'docker/swarm/swarm' require 'docker/swarm/connection' require 'docker/swarm/network' require 'docker/swarm/task'
# File lib/docker-swarm.rb, line 38 def default_socket_url 'unix:///var/run/docker.sock' end
# File lib/docker-swarm.rb, line 46 def env_options 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(ssl_options) else {} end end
# File lib/docker-swarm.rb, line 42 def env_url ENV['DOCKER_URL'] || ENV['DOCKER_HOST'] end
Get more information about the Docker
server.
# File lib/docker-swarm.rb, line 112 def info(connection = self.connection) Util.parse_json(connection.get('/info')) end
# File lib/docker-swarm.rb, line 78 def options @options ||= env_options end
# File lib/docker-swarm.rb, line 87 def options=(new_options) @options = env_options.merge(new_options || {}) reset_connection! end
Ping the Docker
server.
# File lib/docker-swarm.rb, line 117 def ping(connection = self.connection) connection.get('/_ping') end
# File lib/docker-swarm.rb, line 96 def reset! @url = nil @options = nil reset_connection! end
# File lib/docker-swarm.rb, line 102 def reset_connection! @connection = nil end
# File lib/docker-swarm.rb, line 59 def ssl_options if ENV['DOCKER_SSL_VERIFY'] == 'false' { ssl_verify_peer: false } else {} end end
# File lib/docker-swarm.rb, line 69 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
# File lib/docker-swarm.rb, line 82 def url=(new_url) @url = new_url reset_connection! end
When the correct version of Docker
is installed, returns true. Otherwise, raises a VersionError.
# File lib/docker-swarm.rb, line 133 def validate_version! Docker.info true rescue Docker::Error::DockerError raise Docker::Error::VersionError, "Expected API Version: #{API_VERSION}" end
Get the version of Go, Docker
, and optionally the Git commit.
# File lib/docker-swarm.rb, line 107 def version(connection = self.connection) Util.parse_json(connection.get('/version')) end
Private Instance Methods
Login to the Docker
registry.
# File lib/docker-swarm.rb, line 122 def authenticate!(options = {}, connection = self.connection) creds = options.to_json connection.post('/auth', {}, :body => creds) @creds = creds true rescue Docker::Error::ServerError, Docker::Error::UnauthorizedError raise Docker::Error::AuthenticationError end
# File lib/docker-swarm.rb, line 92 def connection @connection ||= Connection.new(url, options) end
require 'docker/swarm/node' require 'docker/swarm/service' require 'docker/swarm/swarm' require 'docker/swarm/connection' require 'docker/swarm/network' require 'docker/swarm/task'
# File lib/docker-swarm.rb, line 38 def default_socket_url 'unix:///var/run/docker.sock' end
# File lib/docker-swarm.rb, line 46 def env_options 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(ssl_options) else {} end end
# File lib/docker-swarm.rb, line 42 def env_url ENV['DOCKER_URL'] || ENV['DOCKER_HOST'] end
Get more information about the Docker
server.
# File lib/docker-swarm.rb, line 112 def info(connection = self.connection) Util.parse_json(connection.get('/info')) end
# File lib/docker-swarm.rb, line 78 def options @options ||= env_options end
# File lib/docker-swarm.rb, line 87 def options=(new_options) @options = env_options.merge(new_options || {}) reset_connection! end
Ping the Docker
server.
# File lib/docker-swarm.rb, line 117 def ping(connection = self.connection) connection.get('/_ping') end
# File lib/docker-swarm.rb, line 96 def reset! @url = nil @options = nil reset_connection! end
# File lib/docker-swarm.rb, line 102 def reset_connection! @connection = nil end
# File lib/docker-swarm.rb, line 59 def ssl_options if ENV['DOCKER_SSL_VERIFY'] == 'false' { ssl_verify_peer: false } else {} end end
# File lib/docker-swarm.rb, line 69 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
# File lib/docker-swarm.rb, line 82 def url=(new_url) @url = new_url reset_connection! end
When the correct version of Docker
is installed, returns true. Otherwise, raises a VersionError.
# File lib/docker-swarm.rb, line 133 def validate_version! Docker.info true rescue Docker::Error::DockerError raise Docker::Error::VersionError, "Expected API Version: #{API_VERSION}" end
Get the version of Go, Docker
, and optionally the Git commit.
# File lib/docker-swarm.rb, line 107 def version(connection = self.connection) Util.parse_json(connection.get('/version')) end