diff --git a/app/models/git_repository.rb b/app/models/git_repository.rb index 71f5c1113e34..df9b10e770c9 100644 --- a/app/models/git_repository.rb +++ b/app/models/git_repository.rb @@ -231,9 +231,20 @@ def worktree_params params[:password] = auth.password end end + params[:proxy_url] = proxy_url if proxy_url? params end + def proxy_url? + !!Settings.git_repository_proxy.host + end + + def proxy_url + uri_opts = Settings.git_repository_proxy.to_h.slice(:host, :port, :scheme, :path) + uri_opts[:path] ||= "/" + URI::Generic.build(uri_opts).to_s + end + def broadcast_repo_dir_delete MiqQueue.broadcast( :class_name => self.class.name, diff --git a/config/settings.yml b/config/settings.yml index c75cac9698c3..8d2ab908e82e 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -840,6 +840,7 @@ :port: :user: :scheme: + :path: :help_menu: :documentation: :type: default diff --git a/spec/models/git_repository_spec.rb b/spec/models/git_repository_spec.rb index faea80aa7da6..ff344f097eb9 100644 --- a/spec/models/git_repository_spec.rb +++ b/spec/models/git_repository_spec.rb @@ -93,6 +93,19 @@ expect(repo.default_authentication.password).to eq(password) end + it "sends the proxy settings to the worktree instance" do + stub_settings(:git_repository_proxy => { + :host => "example.com", + :port => "80", + :scheme => "http", + :path => "/proxy" + }) + expect(GitWorktree).to receive(:new).with(hash_including(:proxy_url => "http://example.com:80/proxy")).twice.times.and_return(gwt) + expect(gwt).to receive(:pull).with(no_args) + + repo.refresh + end + context "self signed certifcate" do let(:verify_ssl) { OpenSSL::SSL::VERIFY_NONE }