diff options
Diffstat (limited to 'ruby/gitlab-shell/lib/gitlab_config.rb')
-rw-r--r-- | ruby/gitlab-shell/lib/gitlab_config.rb | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/ruby/gitlab-shell/lib/gitlab_config.rb b/ruby/gitlab-shell/lib/gitlab_config.rb index 3ccadf9ee..beb08b29c 100644 --- a/ruby/gitlab-shell/lib/gitlab_config.rb +++ b/ruby/gitlab-shell/lib/gitlab_config.rb @@ -2,15 +2,19 @@ require 'yaml' require 'json' class GitlabConfig + def root_path + Pathname.new(fetch_from_config('root_path', File.expand_path('..', __dir__)).freeze)) + end + def secret_file - fetch_from_config('secret_file', fetch_from_legacy_config('secret_file', File.join(ROOT_PATH, '.gitlab_shell_secret'))) + fetch_from_config('secret_file', fetch_from_legacy_config('secret_file', File.join(root_path, '.gitlab_shell_secret'))) end # Pass a default value because this is called from a repo's context; in which # case, the repo's hooks directory should be the default. # def custom_hooks_dir(default: nil) - fetch_from_config('custom_hooks_dir', fetch_from_legacy_config('custom_hooks_dir', File.join(ROOT_PATH, 'hooks'))) + fetch_from_config('custom_hooks_dir', fetch_from_legacy_config('custom_hooks_dir', File.join(root_path, 'hooks'))) end def gitlab_url @@ -22,27 +26,17 @@ class GitlabConfig end def log_file - log_path = Pathname.new(fetch_from_config('log_path', LOG_PATH)) - - log_path = ROOT_PATH if log_path === '' + log_path = Pathname.new(fetch_from_config('log_path', root_path)) return log_path.join('gitlab-shell.log') end def log_level - log_level = fetch_from_config('log_level', LOG_LEVEL) - - return log_level unless log_level.empty? - - 'INFO' + fetch_from_config('log_level', 'INFO') end def log_format - log_format = fetch_from_config('log_format', LOG_FORMAT) - - return log_format unless log_format.empty? - - 'text' + fetch_from_config('log_format', 'text') end def to_json @@ -77,7 +71,7 @@ class GitlabConfig def legacy_config # TODO: deprecate @legacy_config that is parsing the gitlab-shell config.yml - legacy_file = ROOT_PATH.join('config.yml') + legacy_file = root_path.join('config.yml') return {} unless legacy_file.exist? @legacy_config ||= YAML.load_file(legacy_file) |