diff --git a/CHANGELOG b/CHANGELOG index 8a0f2d9..70a3e62 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ - Make SSH port in clone URLs configurable (Julien Pivotto) - Fix default Postgres port for non-packaged DBMS (Drew Blessing) - Add migration instructions coming from an existing GitLab installation (Goni Zahavy) +- Add a gitlab.yml conversion support script 6.8.1 - Use gitlab-rails 6.8.1 diff --git a/support/gitlab_yml_converter.rb b/support/gitlab_yml_converter.rb new file mode 100644 index 0000000..82e656e --- /dev/null +++ b/support/gitlab_yml_converter.rb @@ -0,0 +1,44 @@ +# This script translates settings from a gitlab.yml file to the format of +# omnibus-gitlab's /etc/gitlab/gitlab.rb file. +# +# The output is NOT a valid gitlab.rb file! The purpose of this script is only +# to reduce copy and paste work. +# +# Usage: ruby gitlab_yml_converter.rb /path/to/gitlab.yml + +require 'yaml' + +module GitlabYamlConverter + class Flattener + def initialize(separator='_') + @separator = separator + end + + def flatten(hash, prefix=nil) + Enumerator.new do |yielder| + hash.each do |key, value| + raise "Bad key: #{key.inspect}" unless key.is_a?(String) + key = [prefix, key].join(@separator) if prefix + + if value.is_a?(Hash) + flatten(value, key).each do |nested_key_value| + yielder.yield nested_key_value + end + else + yielder.yield [key, value] + end + end + end + end + end + + def self.convert(gitlab_yml) + Flattener.new.flatten(gitlab_yml['production']).each do |key, value| + puts "gitlab_rails['#{key}'] = #{value.inspect}" + end + end +end + +if $0 == __FILE__ + GitlabYamlConverter.convert(YAML.load(ARGF.read)) +end -- libgit2 0.21.2