summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-01-16 17:52:52 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-01-19 21:58:06 -0300
commit81dd626b9b09550983e7c3ba4aba1420e870e49b (patch)
tree11f8cdc10ca1026b78b449a8fbff9145153fbc4d
parentcf1f7e89c9d948a96a1c637183a1c1f076fda27c (diff)
downloadgitlab-ce-gitaly-api.tar.gz
Add internal API endpoint to share Gitaly's paths with other componentsgitaly-api
-rw-r--r--changelogs/unreleased/gitaly-api.yml4
-rw-r--r--lib/api/internal.rb6
-rw-r--r--spec/requests/api/internal_spec.rb14
3 files changed, 24 insertions, 0 deletions
diff --git a/changelogs/unreleased/gitaly-api.yml b/changelogs/unreleased/gitaly-api.yml
new file mode 100644
index 00000000000..9edc68b0965
--- /dev/null
+++ b/changelogs/unreleased/gitaly-api.yml
@@ -0,0 +1,4 @@
+---
+title: Add internal API endpoint to share Gitaly's paths with other components
+merge_request: 8618
+author:
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index d235977fbd8..6fa71e338ee 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -132,6 +132,12 @@ module API
{ success: true, recovery_codes: codes }
end
+
+ get '/gitaly' do
+ status 200
+
+ { socket_path: Gitlab.config.gitaly.socket_path }
+ end
end
end
end
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb
index a3798c8cd6c..b8881cbe815 100644
--- a/spec/requests/api/internal_spec.rb
+++ b/spec/requests/api/internal_spec.rb
@@ -412,6 +412,20 @@ describe API::Internal, api: true do
end
end
+ describe 'GET /internal/gitaly' do
+ before do
+ allow(Gitlab.config).to receive(:gitaly).and_return(Settingslogic.new('socket_path' => '/my/gitaly.socket'))
+
+ get api("/internal/gitaly"), secret_token: secret_token
+ end
+
+ it 'returns the gitaly socket path' do
+ expect(response.status).to eq(200)
+
+ expect(json_response['socket_path']).to eq('/my/gitaly.socket')
+ end
+ end
+
def project_with_repo_path(path)
double().tap do |fake_project|
allow(fake_project).to receive_message_chain('repository.path_to_repo' => path)