Class: Gitlab::QA::Docker::Volumes

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/docker/volumes.rb

Constant Summary collapse

VOLUMES =
{ 'config' => '/etc/gitlab',
'data' => '/var/opt/gitlab' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(volumes = VOLUMES) ⇒ Volumes

Returns a new instance of Volumes.



10
11
12
# File 'lib/gitlab/qa/docker/volumes.rb', line 10

def initialize(volumes = VOLUMES)
  @volumes = volumes
end

Instance Method Details

#with_temporary_volumesObject



14
15
16
17
18
19
20
21
# File 'lib/gitlab/qa/docker/volumes.rb', line 14

def with_temporary_volumes
  # macOS's tmpdir is a symlink /var/folders -> /private/var/folders
  # but Docker on macOS exposes /private and disallow exposing /var/
  # so we need to get the real tmpdir path
  Dir.mktmpdir('gitlab-qa-', File.realpath(Dir.tmpdir)).tap do |dir|
    yield Hash[@volumes.map { |k, v| ["#{dir}/#{k}", v] }]
  end
end