class Docker::Stack::Localstack::EndpointStub::Plugin

Constants

PORT_MAP

Public Instance Methods

after_initialize(client) click to toggle source
# File lib/docker/stack/localstack/endpoint_stub.rb, line 31
def after_initialize(client)
  client.config.endpoint = endpoint_for(client) || client.config.endpoint
end

Private Instance Methods

endpoint_for(client) click to toggle source
# File lib/docker/stack/localstack/endpoint_stub.rb, line 37
def endpoint_for(client)
  base_port = PORT_MAP[client.class.parent_name]
  return nil if base_port.nil?
  base_url = ENV['LOCALSTACK_ENDPOINT'] || 'http://localhost'
  offset = ENV['LOCALSTACK_OFFSET']&.to_i || Docker::Stack.port_for(:localstack)
  base_uri = URI.parse(base_url)
  base_uri.port = base_port + offset
  base_uri.to_s
end