Sha256: 7f7aefd40c603d2505b22ec5f8205d887043ff2138a9a1b0731f788eb9a11e73

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 KB

Contents

module Minke
  module Docker
    ##
    # ServiceDiscovery allows you to look up the publicly accessible address and port for a server
    class ServiceDiscovery
      def initialize config
        reader = Minke::Config::Reader.new
        @config = reader.read config
      end

      ##
      # Will attempt to locate the public details for a running container given
      # its name and private port
      # Parameters:
      # - container_name: the name of the running container
      # - private_port: the private port which you wish to retrieve an address for
      # - task: :run, :cucumber search either the run or cucumber section of the config
      def public_address_for container_name, private_port, task
        compose = Minke::Docker::DockerCompose.new @config.compose_file_for(task), Minke::Docker::SystemRunner.new
        docker_runner = Minke::Docker::DockerRunner.new

        public_address = compose.public_address container_name, private_port

        ip = docker_runner.get_docker_ip_address
        if  ip != "127.0.0.1" && ip != "0.0.0.0" && ip != nil
          public_address.gsub!('0.0.0.0', ip)
        end

        public_address
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
minke-1.6.1 lib/minke/docker/service_discovery.rb
minke-1.6.0 lib/minke/docker/service_discovery.rb
minke-1.5.9 lib/minke/docker/service_discovery.rb
minke-1.5.8 lib/minke/docker/service_discovery.rb
minke-1.5.7 lib/minke/docker/service_discovery.rb
minke-1.5.6 lib/minke/docker/service_discovery.rb
minke-1.5.5 lib/minke/docker/service_discovery.rb
minke-1.5.4 lib/minke/docker/service_discovery.rb
minke-1.5.3 lib/minke/docker/service_discovery.rb
minke-1.5.2 lib/minke/docker/service_discovery.rb
minke-1.5.1 lib/minke/docker/service_discovery.rb
minke-1.5.0 lib/minke/docker/service_discovery.rb
minke-1.4.0 lib/minke/docker/service_discovery.rb
minke-1.3.0 lib/minke/docker/service_discovery.rb
minke-1.2.0 lib/minke/docker/service_discovery.rb
minke-1.1.0 lib/minke/docker/service_discovery.rb
minke-1.0.9 lib/minke/docker/service_discovery.rb
minke-1.0.8 lib/minke/docker/service_discovery.rb
minke-1.0.7 lib/minke/docker/service_discovery.rb
minke-1.0.6 lib/minke/docker/service_discovery.rb