Class: Gitlab::QA::Component::InternetTunnel

Inherits:
Object
  • Object
show all
Includes:
Scenario::Actable
Defined in:
lib/gitlab/qa/component/internet_tunnel.rb

Constant Summary collapse

DOCKER_IMAGE =
'gitlab/ssh-tunnel'.freeze
DOCKER_IMAGE_TAG =
'1.0.0'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Scenario::Actable

#act, included

Constructor Details

#initializeInternetTunnel

Returns a new instance of InternetTunnel.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/qa/component/internet_tunnel.rb', line 15

def initialize
  @docker = Docker::Engine.new
  @volumes = {}

  key_dir = ENV['CI_PROJECT_DIR'] || Dir.tmpdir
  @ssh_key = Tempfile.new('tunnel-ssh-private-key', key_dir)
  @ssh_key.write(ENV.fetch('TUNNEL_SSH_PRIVATE_KEY'))
  @ssh_key.close

  File.chmod(0o600, @ssh_key.path)

  @volumes['/root/.ssh/id_rsa'] = @ssh_key.path
end

Instance Attribute Details

#gitlab_hostname=(value) ⇒ Object (writeonly)

Sets the attribute gitlab_hostname

Parameters:

  • value

    the value to set the attribute gitlab_hostname to.



12
13
14
# File 'lib/gitlab/qa/component/internet_tunnel.rb', line 12

def gitlab_hostname=(value)
  @gitlab_hostname = value
end

#name=(value) ⇒ Object

Sets the attribute name

Parameters:

  • value

    the value to set the attribute name to.



12
13
14
# File 'lib/gitlab/qa/component/internet_tunnel.rb', line 12

def name=(value)
  @name = value
end

#networkObject

Returns the value of attribute network.



13
14
15
# File 'lib/gitlab/qa/component/internet_tunnel.rb', line 13

def network
  @network
end

Instance Method Details

#instanceObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/qa/component/internet_tunnel.rb', line 29

def instance
  raise ArgumentError, 'Please provide a block!' unless block_given?

  prepare
  start

  yield self
ensure
  teardown
end

#urlObject



40
41
42
# File 'lib/gitlab/qa/component/internet_tunnel.rb', line 40

def url
  "https://#{subdomain}.#{tunnel_server_hostname}"
end