Commit f3b83553 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Make gitaly executable mapping clearer

parent 2a163a17
...@@ -10,7 +10,10 @@ class GitlabShell ...@@ -10,7 +10,10 @@ class GitlabShell
class InvalidRepositoryPathError < StandardError; end class InvalidRepositoryPathError < StandardError; end
GIT_COMMANDS = %w(git-upload-pack git-receive-pack git-upload-archive git-lfs-authenticate).freeze GIT_COMMANDS = %w(git-upload-pack git-receive-pack git-upload-archive git-lfs-authenticate).freeze
GITALY_MIGRATED_COMMANDS = %w(git-upload-pack git-receive-pack) GITALY_MIGRATED_COMMANDS = {
'git-upload-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-upload-pack'),
'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack'),
}
API_COMMANDS = %w(2fa_recovery_codes) API_COMMANDS = %w(2fa_recovery_codes)
GL_PROTOCOL = 'ssh'.freeze GL_PROTOCOL = 'ssh'.freeze
...@@ -109,26 +112,27 @@ class GitlabShell ...@@ -109,26 +112,27 @@ class GitlabShell
return return
end end
args = [@command, repo_path] executable = @command
args = [repo_path]
if GITALY_MIGRATED_COMMANDS.include?(args[0]) if GITALY_MIGRATED_COMMANDS.has_key?(executable)
executable = args[0].sub('git', File.join(ROOT_PATH, 'bin/gitaly')) executable = GITALY_MIGRATED_COMMANDS[executable]
gitaly_address = '' # would be returned by gitlab-rails internal API gitaly_address = '' # would be returned by gitlab-rails internal API
# The entire gitaly_request hash should be built in gitlab-ce and passed # The entire gitaly_request hash should be built in gitlab-ce and passed
# on as-is. For now we build a fake one on the spot. # on as-is. For now we build a fake one on the spot.
gitaly_request = JSON.dump({ gitaly_request = JSON.dump({
'repository' => { 'path' => args[1] }, 'repository' => { 'path' => repo_path },
'gl_id' => @key_id, 'gl_id' => @key_id,
}) })
args = [executable, gitaly_address, gitaly_request] args = [gitaly_address, gitaly_request]
end end
args_string = [File.basename(args[0]), *args[1, args.length]].join(' ') args_string = [File.basename(executable), *args].join(' ')
$logger.info "gitlab-shell: executing git command <#{args_string}> for #{log_username}." $logger.info "gitlab-shell: executing git command <#{args_string}> for #{log_username}."
exec_cmd(*args) exec_cmd(executable, *args)
end end
# This method is not covered by Rspec because it ends the current Ruby process. # This method is not covered by Rspec because it ends the current Ruby process.
......
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