Commit 3b7ffb355d46cb37c595e27f94c3ce377d3848fa
1 parent
778b26bf
Exists in
master
and in
11 other branches
Add a gitlab.yml conversion support script
Showing
2 changed files
with
45 additions
and
0 deletions
Show diff stats
CHANGELOG
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | - Make SSH port in clone URLs configurable (Julien Pivotto) |
3 | 3 | - Fix default Postgres port for non-packaged DBMS (Drew Blessing) |
4 | 4 | - Add migration instructions coming from an existing GitLab installation (Goni Zahavy) |
5 | +- Add a gitlab.yml conversion support script | |
5 | 6 | |
6 | 7 | 6.8.1 |
7 | 8 | - Use gitlab-rails 6.8.1 | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +# This script translates settings from a gitlab.yml file to the format of | |
2 | +# omnibus-gitlab's /etc/gitlab/gitlab.rb file. | |
3 | +# | |
4 | +# The output is NOT a valid gitlab.rb file! The purpose of this script is only | |
5 | +# to reduce copy and paste work. | |
6 | +# | |
7 | +# Usage: ruby gitlab_yml_converter.rb /path/to/gitlab.yml | |
8 | + | |
9 | +require 'yaml' | |
10 | + | |
11 | +module GitlabYamlConverter | |
12 | + class Flattener | |
13 | + def initialize(separator='_') | |
14 | + @separator = separator | |
15 | + end | |
16 | + | |
17 | + def flatten(hash, prefix=nil) | |
18 | + Enumerator.new do |yielder| | |
19 | + hash.each do |key, value| | |
20 | + raise "Bad key: #{key.inspect}" unless key.is_a?(String) | |
21 | + key = [prefix, key].join(@separator) if prefix | |
22 | + | |
23 | + if value.is_a?(Hash) | |
24 | + flatten(value, key).each do |nested_key_value| | |
25 | + yielder.yield nested_key_value | |
26 | + end | |
27 | + else | |
28 | + yielder.yield [key, value] | |
29 | + end | |
30 | + end | |
31 | + end | |
32 | + end | |
33 | + end | |
34 | + | |
35 | + def self.convert(gitlab_yml) | |
36 | + Flattener.new.flatten(gitlab_yml['production']).each do |key, value| | |
37 | + puts "gitlab_rails['#{key}'] = #{value.inspect}" | |
38 | + end | |
39 | + end | |
40 | +end | |
41 | + | |
42 | +if $0 == __FILE__ | |
43 | + GitlabYamlConverter.convert(YAML.load(ARGF.read)) | |
44 | +end | ... | ... |