As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 7d7bde94 authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Process commands with Gitaly if a flag is passed from the app

parent a3712cc1
No related branches found
No related tags found
No related merge requests found
require 'json'
class GitAccessStatus
attr_reader :message, :repository_path
attr_reader :message, :repository_path, :gitaly_address
def initialize(status, message, repository_path)
def initialize(status, message, repository_path, gitaly_address = nil)
@status = status
@message = message
@repository_path = repository_path
@gitaly_address = gitaly_address
end
def self.create_from_json(json)
values = JSON.parse(json)
self.new(values["status"], values["message"], values["repository_path"])
self.new(values["status"], values["message"], values["repository_path"], values["gitaly_address"])
end
def allowed?
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ class GitlabShell
API_COMMANDS = %w(2fa_recovery_codes)
GL_PROTOCOL = 'ssh'.freeze
attr_accessor :key_id, :repo_name, :command, :git_access
attr_accessor :key_id, :repo_name, :command, :git_access, :gitaly_address
attr_reader :repo_path
def initialize(key_id)
Loading
Loading
@@ -98,6 +98,7 @@ class GitlabShell
raise AccessDeniedError, status.message unless status.allowed?
self.repo_path = status.repository_path
self.gitaly_address = status.gitaly_address
end
def process_cmd(args)
Loading
Loading
@@ -126,9 +127,14 @@ class GitlabShell
$logger.info "gitlab-shell: Processing LFS authentication for #{log_username}."
lfs_authenticate
end
else
end
if gitaly_address.nil?
$logger.info "gitlab-shell: executing git command <#{@command} #{repo_path}> for #{log_username}."
exec_cmd(@command, repo_path)
else
$logger.info "gitlab-shell: processing with gitaly <#{gitaly_address}> command: <#{@command}> repo: <#{repo_path}> for <#{log_username}>."
process_cmd_with_gitaly(@command, repo_path)
end
end
Loading
Loading
@@ -165,6 +171,10 @@ class GitlabShell
Kernel::exec(env, *args, unsetenv_others: true)
end
def process_cmd_with_gitaly(cmd, repo_path)
# To be implemented
end
def api
GitlabNet.new
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment