Module: Gitlab::SetupHelper

Included in:
Gitaly, Praefect, Workhorse
Defined in:
lib/gitlab/setup_helper.rb

Defined Under Namespace

Modules: Gitaly, Praefect, Workhorse

Instance Method Summary collapse

Instance Method Details

#create_configuration(dir, storage_paths, force: false, options: {}) ⇒ Object


7
8
9
10
11
12
13
# File 'lib/gitlab/setup_helper.rb', line 7

def create_configuration(dir, storage_paths, force: false, options: {})
  generate_configuration(
    configuration_toml(dir, storage_paths, options),
    get_config_path(dir, options),
    force: force
  )
end

#generate_configuration(toml_data, config_path, force: false) ⇒ Object

rubocop:disable Rails/Output


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/setup_helper.rb', line 16

def generate_configuration(toml_data, config_path, force: false)
  FileUtils.rm_f(config_path) if force

  File.open(config_path, File::WRONLY | File::CREAT | File::EXCL) do |f|
    f.puts toml_data
  end
rescue Errno::EEXIST
  puts 'Skipping config.toml generation:'
  puts "A configuration file for #{config_path} already exists."
rescue ArgumentError => e
  puts 'Skipping config.toml generation:'
  puts e.message
end