diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-12-27 13:19:52 +0200 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-12-27 13:27:34 +0200 |
commit | 7d7bde94745b793ae76049d8c8ad54314a762d29 (patch) | |
tree | 1a0293fd4334803d0157f8fa9f20022280726fed | |
parent | a3712cc18de8283b25c3a8a034ecc8c9b7feca48 (diff) | |
download | gitlab-shell-feature/gitaly-feature-flag.tar.gz |
Process commands with Gitaly if a flag is passed from the appfeature/gitaly-feature-flag
-rw-r--r-- | lib/gitlab_access_status.rb | 7 | ||||
-rw-r--r-- | lib/gitlab_shell.rb | 14 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/gitlab_access_status.rb b/lib/gitlab_access_status.rb index 7fb88be..b5433e4 100644 --- a/lib/gitlab_access_status.rb +++ b/lib/gitlab_access_status.rb @@ -1,17 +1,18 @@ 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? diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index e243aac..2b728ad 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -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) @@ -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) @@ -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 @@ -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 |