diff options
author | Robert Speicher <robert@gitlab.com> | 2017-01-19 17:39:44 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-01-19 17:39:44 +0000 |
commit | c84272dc9a5c2d9619347f91b4e316431dada975 (patch) | |
tree | 4508b74d69835e979654a6933bcb17fdbc8c5cb9 | |
parent | 639b880e702f35819439c234dbda3168787f29fd (diff) | |
parent | 0a1c8bb37cbfe550e7c29b8f30c607cf985466df (diff) | |
download | gitlab-ce-c84272dc9a5c2d9619347f91b4e316431dada975.tar.gz |
Merge branch 'feature/gitaly-feature-flag' into 'master'
Gitaly feature flag
See merge request !8440
-rw-r--r-- | changelogs/unreleased/feature-gitaly-feature-flag.yml | 4 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/workhorse.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/workhorse_spec.rb | 23 |
4 files changed, 41 insertions, 1 deletions
diff --git a/changelogs/unreleased/feature-gitaly-feature-flag.yml b/changelogs/unreleased/feature-gitaly-feature-flag.yml new file mode 100644 index 00000000000..1fa566aeb10 --- /dev/null +++ b/changelogs/unreleased/feature-gitaly-feature-flag.yml @@ -0,0 +1,4 @@ +--- +title: Pass Gitaly resource path to gitlab-workhorse if Gitaly is enabled +merge_request: 8440 +author: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index ee97b4e42b9..906ec11f012 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -404,6 +404,12 @@ Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour # +# Gitaly +# +Settings['gitaly'] ||= Settingslogic.new({}) +Settings.gitaly['socket_path'] ||= ENV['GITALY_SOCKET_PATH'] + +# # Testing settings # if Rails.env.test? diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index d28bb583fe7..a3b502ffd6a 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -15,10 +15,17 @@ module Gitlab class << self def git_http_ok(repository, user) - { + params = { GL_ID: Gitlab::GlId.gl_id(user), RepoPath: repository.path_to_repo, } + + params.merge!( + GitalySocketPath: Gitlab.config.gitaly.socket_path, + GitalyResourcePath: "/projects/#{repository.project.id}/git-http/info-refs", + ) if Gitlab.config.gitaly.socket_path.present? + + params end def lfs_upload_ok(oid, size) diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index 61da91dcbd3..4b1cd466677 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -174,4 +174,27 @@ describe Gitlab::Workhorse, lib: true do described_class.verify_api_request!(headers) end end + + describe '.git_http_ok' do + let(:user) { create(:user) } + + subject { described_class.git_http_ok(repository, user) } + + it { expect(subject).to eq({ GL_ID: "user-#{user.id}", RepoPath: repository.path_to_repo }) } + + context 'when Gitaly socket path is present' do + let(:gitaly_socket_path) { '/tmp/gitaly.sock' } + + before do + allow(Gitlab.config.gitaly).to receive(:socket_path).and_return(gitaly_socket_path) + end + + it 'includes Gitaly params in the returned value' do + expect(subject).to include({ + GitalyResourcePath: "/projects/#{repository.project.id}/git-http/info-refs", + GitalySocketPath: gitaly_socket_path, + }) + end + end + end end |