Sha256: e08ebffb02f3d86d3f60878564a7c0cd07faaceff836c7ccd783d7a8eb5a5a57
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
require 'singleton' require 'docker' module Percheron class Connection include Singleton # rubocop:disable Style/ClassVars def self.load!(config) @@config = config instance.setup! instance end # rubocop:enable Style/ClassVars def self.perform(klass, method, *args) instance.perform(klass, method, *args) end def perform(klass, method, *args) klass.public_send(method, *args) rescue => e $logger.debug '%s.%s(%s) - %s' % [ klass, method, args, e.inspect ] raise end def setup! set_url! set_options! end private def config @@config end def cert_path @cert_path ||= ENV['DOCKER_CERT_PATH'] ? File.expand_path(ENV['DOCKER_CERT_PATH']) : nil end def set_url! Docker.url = config.docker.host end def set_options! Excon.defaults[:ssl_verify_peer] = config.docker.fetch('ssl_verify_peer', true) Docker.options = docker_options end def docker_options base_docker_options.merge(extra_docker_opts) end def base_docker_options { connect_timeout: config.docker.connect_timeout || 5, read_timeout: config.docker.read_timeout || 300 } end def extra_docker_opts return {} unless cert_path { client_cert: cert_path_for('cert.pem'), client_key: cert_path_for('key.pem'), ssl_ca_file: cert_path_for('ca.pem') } end def cert_path_for(file) File.join(cert_path, file) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
percheron-0.7.10 | lib/percheron/connection.rb |
percheron-0.7.9 | lib/percheron/connection.rb |
percheron-0.7.8 | lib/percheron/connection.rb |
percheron-0.7.7 | lib/percheron/connection.rb |