From e3cacb95a85080c9bd8993b26e996d952fbab05f Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 25 Jan 2019 14:10:04 +0200 Subject: [PATCH] Add connection_data method to Gitaly client Backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7434 --- lib/gitlab/gitaly_client.rb | 6 +++++- spec/lib/gitlab/gitaly_client_spec.rb | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 8bf8a3b53cd..d16cda3dc4a 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -126,7 +126,11 @@ module Gitlab end def self.address_metadata(storage) - Base64.strict_encode64(JSON.dump({ storage => { 'address' => address(storage), 'token' => token(storage) } })) + Base64.strict_encode64(JSON.dump(storage => connection_data(storage))) + end + + def self.connection_data(storage) + { 'address' => address(storage), 'token' => token(storage) } end # All Gitaly RPC call sites should use GitalyClient.call. This method diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index e41a75c37a7..cf12baf1a93 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -119,6 +119,15 @@ describe Gitlab::GitalyClient do end end + describe '.connection_data' do + it 'returns connection data' do + address = 'tcp://localhost:9876' + stub_repos_storages address + + expect(described_class.connection_data('default')).to eq({ 'address' => address, 'token' => 'secret' }) + end + end + describe 'allow_n_plus_1_calls' do context 'when RequestStore is enabled', :request_store do it 'returns the result of the allow_n_plus_1_calls block' do