diff options
author | Robert Speicher <rspeicher@gmail.com> | 2018-11-20 13:43:24 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-11-20 13:43:24 +0000 |
commit | 9fe85710f6bfae2363c01c827be434506ddca00a (patch) | |
tree | d30b066658df669efab8bceb14f9986bdfc02f58 /lib | |
parent | 2ea250d4bff03b656403e85db14cc5a4be593c67 (diff) | |
parent | f1bc7b6eb5cb9beab55e4edac87cc5e0b7ceb069 (diff) | |
download | gitlab-ce-9fe85710f6bfae2363c01c827be434506ddca00a.tar.gz |
Merge branch '49565-ssh-push-mirroring' into 'master'
SSH public-key authentication for push mirroring
Closes #49565
See merge request gitlab-org/gitlab-ce!22982
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/remote_mirror.rb | 16 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/remote_service.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 2 |
3 files changed, 21 insertions, 6 deletions
diff --git a/lib/gitlab/git/remote_mirror.rb b/lib/gitlab/git/remote_mirror.rb index e992d522e7f..df3cd422527 100644 --- a/lib/gitlab/git/remote_mirror.rb +++ b/lib/gitlab/git/remote_mirror.rb @@ -5,14 +5,24 @@ module Gitlab class RemoteMirror include Gitlab::Git::WrapsGitalyErrors - def initialize(repository, ref_name) + attr_reader :repository, :ref_name, :only_branches_matching, :ssh_key, :known_hosts + + def initialize(repository, ref_name, only_branches_matching: [], ssh_key: nil, known_hosts: nil) @repository = repository @ref_name = ref_name + @only_branches_matching = only_branches_matching + @ssh_key = ssh_key + @known_hosts = known_hosts end - def update(only_branches_matching: []) + def update wrapped_gitaly_errors do - @repository.gitaly_remote_client.update_remote_mirror(@ref_name, only_branches_matching) + repository.gitaly_remote_client.update_remote_mirror( + ref_name, + only_branches_matching, + ssh_key: ssh_key, + known_hosts: known_hosts + ) end end end diff --git a/lib/gitlab/gitaly_client/remote_service.rb b/lib/gitlab/gitaly_client/remote_service.rb index 24e8a5e16d3..81fac37ee68 100644 --- a/lib/gitlab/gitaly_client/remote_service.rb +++ b/lib/gitlab/gitaly_client/remote_service.rb @@ -68,13 +68,18 @@ module Gitlab encode_utf8(response.ref) end - def update_remote_mirror(ref_name, only_branches_matching) + def update_remote_mirror(ref_name, only_branches_matching, ssh_key: nil, known_hosts: nil) req_enum = Enumerator.new do |y| - y.yield Gitaly::UpdateRemoteMirrorRequest.new( + first_request = Gitaly::UpdateRemoteMirrorRequest.new( repository: @gitaly_repo, ref_name: ref_name ) + first_request.ssh_key = ssh_key if ssh_key.present? + first_request.known_hosts = known_hosts if known_hosts.present? + + y.yield(first_request) + current_size = 0 slices = only_branches_matching.slice_before do |branch_name| diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index f968ebc2cbf..12a0ee16649 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -69,7 +69,7 @@ module Gitlab no_tags: no_tags, timeout: timeout, no_prune: !prune ) - if ssh_auth&.ssh_import? + if ssh_auth&.ssh_mirror_url? if ssh_auth.ssh_key_auth? && ssh_auth.ssh_private_key.present? request.ssh_key = ssh_auth.ssh_private_key end |