Commit a613dbc7 authored by Jacob Vosmaer's avatar Jacob Vosmaer Committed by Douwe Maan

Make better use of constants in lib/gitlab_shell.rb

parent 03e66710
......@@ -23,8 +23,8 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
GIT_RECEIVE_PACK_COMMAND => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack')
}.freeze
GIT_COMMANDS = (GITALY_COMMANDS.keys + ['git-lfs-authenticate']).freeze
API_COMMANDS = %w(2fa_recovery_codes).freeze
GIT_COMMANDS = (GITALY_COMMANDS.keys + [GIT_LFS_AUTHENTICATE_COMMAND]).freeze
TWO_FACTOR_RECOVERY_COMMAND = '2fa_recovery_codes'
GL_PROTOCOL = 'ssh'
attr_accessor :gl_id, :gl_repository, :repo_name, :command, :git_access, :git_protocol
......@@ -114,7 +114,7 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
@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)
......@@ -151,9 +151,9 @@ class GitlabShell # rubocop:disable Metrics/ClassLength
end
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
operation = args[2]
$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