diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-01-12 14:49:04 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-01-12 14:49:04 +0000 |
commit | a478813e1e0c792733ef4a7639d8191bd20a0261 (patch) | |
tree | 95efafbf9c40d933f796ce2a50df47eb080ad8b6 | |
parent | 58ceab7279066faaaa15e16afb842fee4b7eff49 (diff) | |
parent | 4b84d796181a4e5b20b7f2ecfa7762738a0159d8 (diff) | |
download | gitlab-shell-a478813e1e0c792733ef4a7639d8191bd20a0261.tar.gz |
Merge branch 'sh-remove-geo-node-ssh-keys' into 'master'v6.0.0
Remove special case treatment of Geo nodes for SSH
Closes #115
See merge request gitlab-org/gitlab-shell!179
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | lib/gitlab_access_status.rb | 8 | ||||
-rw-r--r-- | lib/gitlab_net.rb | 3 | ||||
-rw-r--r-- | lib/gitlab_shell.rb | 10 | ||||
-rw-r--r-- | spec/gitlab_access_spec.rb | 6 | ||||
-rw-r--r-- | spec/gitlab_shell_spec.rb | 42 |
7 files changed, 16 insertions, 60 deletions
@@ -1,3 +1,8 @@ +v6.0.0 + - Remove bin/gitlab_projects (!180) + - Remove direct redis integration (!181) + - Remove support unhiding of all references for Geo nodes (!179) + v5.11.0 - Introduce a more-complete implementation of bin/authorized_keys (!178) @@ -1 +1 @@ -5.11.0 +6.0.0 diff --git a/lib/gitlab_access_status.rb b/lib/gitlab_access_status.rb index 69d914e..0b32dc9 100644 --- a/lib/gitlab_access_status.rb +++ b/lib/gitlab_access_status.rb @@ -1,16 +1,15 @@ require 'json' class GitAccessStatus - attr_reader :message, :gl_repository, :gl_username, :repository_path, :gitaly, :geo_node + attr_reader :message, :gl_repository, :gl_username, :repository_path, :gitaly - def initialize(status, message, gl_repository:, gl_username:, repository_path:, gitaly:, geo_node:) + def initialize(status, message, gl_repository:, gl_username:, repository_path:, gitaly:) @status = status @message = message @gl_repository = gl_repository @gl_username = gl_username @repository_path = repository_path @gitaly = gitaly - @geo_node = geo_node end def self.create_from_json(json) @@ -20,8 +19,7 @@ class GitAccessStatus gl_repository: values["gl_repository"], gl_username: values["gl_username"], repository_path: values["repository_path"], - gitaly: values["gitaly"], - geo_node: values["geo_node"]) + gitaly: values["gitaly"]) end def allowed? diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb index 924a784..3f8c280 100644 --- a/lib/gitlab_net.rb +++ b/lib/gitlab_net.rb @@ -44,8 +44,7 @@ class GitlabNet gl_repository: nil, gl_username: nil, repository_path: nil, - gitaly: nil, - geo_node: false) + gitaly: nil) end end diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index e7e7f04..1452f95 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -16,11 +16,8 @@ class GitlabShell } API_COMMANDS = %w(2fa_recovery_codes) GL_PROTOCOL = 'ssh'.freeze - # We have to use a negative transfer.hideRefs since this is the only way - # to undo an already set parameter: https://www.spinics.net/lists/git/msg256772.html - GIT_CONFIG_SHOW_ALL_REFS = "transfer.hideRefs=!refs".freeze - attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :show_all_refs, :username + attr_accessor :key_id, :gl_repository, :repo_name, :command, :git_access, :username attr_reader :repo_path def initialize(key_id) @@ -112,7 +109,6 @@ class GitlabShell self.repo_path = status.repository_path @gl_repository = status.gl_repository @gitaly = status.gitaly - @show_all_refs = status.geo_node @username = status.gl_username end @@ -144,8 +140,6 @@ class GitlabShell 'gl_username' => @username } - gitaly_request['git_config_options'] = [GIT_CONFIG_SHOW_ALL_REFS] if @show_all_refs - args = [gitaly_address, JSON.dump(gitaly_request)] end @@ -177,8 +171,6 @@ class GitlabShell env['GITALY_TOKEN'] = @gitaly['token'] end - env['GIT_CONFIG_PARAMETERS'] = "'#{GIT_CONFIG_SHOW_ALL_REFS}'" if @show_all_refs - if git_trace_available? env.merge!({ 'GIT_TRACE' => @config.git_trace_log_file, diff --git a/spec/gitlab_access_spec.rb b/spec/gitlab_access_spec.rb index 7aea779..c8660a8 100644 --- a/spec/gitlab_access_spec.rb +++ b/spec/gitlab_access_spec.rb @@ -12,8 +12,7 @@ describe GitlabAccess do gl_repository: 'project-1', gl_username: 'testuser', repository_path: '/home/git/repositories', - gitaly: nil, - geo_node: nil)) + gitaly: nil)) end end subject do @@ -50,8 +49,7 @@ describe GitlabAccess do gl_repository: nil, gl_username: nil, repository_path: nil, - gitaly: nil, - geo_node: nil + gitaly: nil )) end diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb index e4873c4..a71e2d0 100644 --- a/spec/gitlab_shell_spec.rb +++ b/spec/gitlab_shell_spec.rb @@ -25,8 +25,7 @@ describe GitlabShell do gl_repository: gl_repository, gl_username: gl_username, repository_path: repo_path, - gitaly: { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' }, - geo_node: false + gitaly: { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' } ) } @@ -39,8 +38,7 @@ describe GitlabShell do gl_repository: gl_repository, gl_username: gl_username, repository_path: repo_path, - gitaly: nil, - geo_node: nil)) + gitaly: nil)) api.stub(two_factor_recovery_codes: { 'success' => true, 'recovery_codes' => ['f67c514de60c4953', '41278385fc00c1e0'] @@ -182,25 +180,6 @@ describe GitlabShell do it_behaves_like 'upload-pack', 'git upload-pack' end - context 'gitaly-upload-pack with GeoNode' do - let(:ssh_cmd) { "git-upload-pack gitlab-ci.git" } - let(:gitaly_check_access_with_geo) { GitAccessStatus.new( - true, - 'ok', - gl_repository: gl_repository, - gl_username: gl_username, - repository_path: repo_path, - gitaly: { 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default'} , 'address' => 'unix:gitaly.socket' }, - geo_node: true) } - let(:gitaly_message_with_all_refs) { JSON.dump({ 'repository' => { 'relative_path' => repo_name, 'storage_name' => 'default' }, 'gl_repository' => gl_repository , 'gl_id' => key_id, 'gl_username' => gl_username, 'git_config_options' => [GitlabShell::GIT_CONFIG_SHOW_ALL_REFS]}) } - before { api.stub(check_access: gitaly_check_access_with_geo) } - after { subject.exec(ssh_cmd) } - - it "should execute the command with unhiding refs" do - subject.should_receive(:exec_cmd).with(File.join(ROOT_PATH, "bin/gitaly-upload-pack"), 'unix:gitaly.socket', gitaly_message_with_all_refs) - end - end - context 'gitaly-upload-pack' do let(:ssh_cmd) { "git-upload-pack gitlab-ci.git" } before { @@ -376,8 +355,7 @@ describe GitlabShell do gl_repository: nil, gl_username: nil, repository_path: nil, - gitaly: nil, - geo_node: nil)) + gitaly: nil)) message = "gitlab-shell: Access denied for git command <git-upload-pack gitlab-ci.git> " message << "by user with key #{key_id}." $logger.should_receive(:warn).with(message) @@ -439,20 +417,6 @@ describe GitlabShell do shell.send :exec_cmd, [1, 2] end - context "when show_all_refs is enabled" do - before { shell.show_all_refs = true } - - it 'sets local git parameters' do - expected_hash = hash_including( - 'GIT_CONFIG_PARAMETERS' => "'transfer.hideRefs=!refs'" - ) - - Kernel.should_receive(:exec).with(expected_hash, [1, 2], exec_options).once - - shell.send :exec_cmd, [1, 2] - end - end - context "when specifying a git_tracing log file" do let(:git_trace_log_file) { '/tmp/git_trace_performance.log' } |