Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2020-04-21 19:50:24 +0300
committerJohn Cai <jcai@gitlab.com>2020-04-22 22:30:16 +0300
commit4da5c3f7c292f41ac5d3cae60e4996933d97d705 (patch)
tree392c6aeab38d020664facb8a9f893c34f3a83fac
parentcb81b140cb41e795dc95485c2940d0cbc7861edb (diff)
Deprecate gitlab init env varsjc-fix-root-path-ruby
-rw-r--r--ruby/gitlab-shell/lib/gitlab_config.rb26
-rw-r--r--ruby/gitlab-shell/lib/gitlab_init.rb8
2 files changed, 10 insertions, 24 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)
diff --git a/ruby/gitlab-shell/lib/gitlab_init.rb b/ruby/gitlab-shell/lib/gitlab_init.rb
index 949135493..188c5e6a5 100644
--- a/ruby/gitlab-shell/lib/gitlab_init.rb
+++ b/ruby/gitlab-shell/lib/gitlab_init.rb
@@ -1,11 +1,3 @@
-# GITLAB_SHELL_DIR has been deprecated
-require 'pathname'
-
-ROOT_PATH = Pathname.new(ENV['GITALY_GITLAB_SHELL_DIR'] || ENV['GITLAB_SHELL_DIR'] || File.expand_path('..', __dir__)).freeze
-LOG_PATH = Pathname.new(ENV.fetch('GITALY_LOG_DIR', ROOT_PATH))
-LOG_LEVEL = ENV.fetch('GITALY_LOG_LEVEL', 'INFO')
-LOG_FORMAT = ENV.fetch('GITALY_LOG_FORMAT', 'text')
-
# We are transitioning parts of gitlab-shell into the gitaly project. In
# gitaly, GITALY_EMBEDDED will be true.
GITALY_EMBEDDED = true