Commit a5dda1a2 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'better-use-of-constants' into 'master'

Make better use of constants in lib/gitlab_shell.rb

See merge request gitlab-org/gitlab-shell!269
parents 03e66710 a613dbc7
...@@ -23,8 +23,8 @@ class GitlabShell # rubocop:disable Metrics/ClassLength ...@@ -23,8 +23,8 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
GIT_RECEIVE_PACK_COMMAND => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack') GIT_RECEIVE_PACK_COMMAND => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack')
}.freeze }.freeze
GIT_COMMANDS = (GITALY_COMMANDS.keys + ['git-lfs-authenticate']).freeze GIT_COMMANDS = (GITALY_COMMANDS.keys + [GIT_LFS_AUTHENTICATE_COMMAND]).freeze
API_COMMANDS = %w(2fa_recovery_codes).freeze TWO_FACTOR_RECOVERY_COMMAND = '2fa_recovery_codes'
GL_PROTOCOL = 'ssh' GL_PROTOCOL = 'ssh'
attr_accessor :gl_id, :gl_repository, :repo_name, :command, :git_access, :git_protocol attr_accessor :gl_id, :gl_repository, :repo_name, :command, :git_access, :git_protocol
...@@ -114,7 +114,7 @@ class GitlabShell # rubocop:disable Metrics/ClassLength ...@@ -114,7 +114,7 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
@git_access = @command @git_access = @command
return args if API_COMMANDS.include?(@command) return args if TWO_FACTOR_RECOVERY_COMMAND == @command
raise DisallowedCommandError unless GIT_COMMANDS.include?(@command) raise DisallowedCommandError unless GIT_COMMANDS.include?(@command)
...@@ -151,9 +151,9 @@ class GitlabShell # rubocop:disable Metrics/ClassLength ...@@ -151,9 +151,9 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
end end
def process_cmd(args) def process_cmd(args)
return send("api_#{@command}") if API_COMMANDS.include?(@command) return api_2fa_recovery_codes if TWO_FACTOR_RECOVERY_COMMAND == @command
if @command == 'git-lfs-authenticate' if @command == GIT_LFS_AUTHENTICATE_COMMAND
GitlabMetrics.measure('lfs-authenticate') do GitlabMetrics.measure('lfs-authenticate') do
operation = args[2] operation = args[2]
$logger.info('Processing LFS authentication', operation: operation, user: log_username) $logger.info('Processing LFS authentication', operation: operation, user: log_username)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment