Sha256: 6b4cdb38a6b61b1a6d092706d19988d058d0a1ed168ce657977247655658a9aa

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

module Percheron
  class DockerConnection

    def initialize(config)
      @config = config
    end

    def setup!
      Docker.logger = $logger if ENV['DOCKER_DEBUG'] == 'true'
      Docker.url = config.docker.host

      opts = {
        chunk_size:       1,
        connect_timeout:  config.docker.timeout,
        scheme:          'https'
      }

      if cert_path
        opts.merge!({
          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')
        })
      end

      Docker.options = opts
    end

    private

      attr_reader :config

      def cert_path
        @cert_path ||= begin
          if ENV['DOCKER_CERT_PATH']
            File.expand_path(ENV['DOCKER_CERT_PATH'])
          else
            nil
          end
        end
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
percheron-0.2.0 lib/percheron/docker_connection.rb