summaryrefslogtreecommitdiff
path: root/lib/chef/provider/subversion.rb
diff options
context:
space:
mode:
authorSalim Alam <salam@chef.io>2016-03-22 15:28:11 -0700
committerSalim Alam <salam@chef.io>2016-03-22 16:44:36 -0700
commite8336f4f930324631b2c2d3dcc999ca0c87fb99c (patch)
treea796b87a31f1b1e24e4b3e1524f3d8037f764fe8 /lib/chef/provider/subversion.rb
parent18f0ee2354ae2539bf63956ef99a37a188ef67eb (diff)
downloadchef-e8336f4f930324631b2c2d3dcc999ca0c87fb99c.tar.gz
Subversion provider should respect proxies
Diffstat (limited to 'lib/chef/provider/subversion.rb')
-rw-r--r--lib/chef/provider/subversion.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index 45002de244..287a9f64a1 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -21,6 +21,7 @@
require "chef/log"
require "chef/provider"
require "chef/mixin/command"
+require "chef-config/mixin/fuzzy_hostname_matcher"
require "fileutils"
class Chef
@@ -32,6 +33,7 @@ class Chef
SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/
include Chef::Mixin::Command
+ include ChefConfig::Mixin::FuzzyHostnameMatcher
def whyrun_supported?
true
@@ -100,21 +102,21 @@ class Chef
end
def sync_command
- c = scm :update, @new_resource.svn_arguments, verbose, authentication, "-r#{revision_int}", @new_resource.destination
+ c = scm :update, @new_resource.svn_arguments, verbose, authentication, proxy, "-r#{revision_int}", @new_resource.destination
Chef::Log.debug "#{@new_resource} updated working copy #{@new_resource.destination} to revision #{@new_resource.revision}"
c
end
def checkout_command
- c = scm :checkout, @new_resource.svn_arguments, verbose, authentication,
- "-r#{revision_int}", @new_resource.repository, @new_resource.destination
+ c = scm :checkout, @new_resource.svn_arguments, verbose, authentication, proxy,
+ "-r#{revision_int}", @new_resource.repository, @new_resource.destination
Chef::Log.info "#{@new_resource} checked out #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
c
end
def export_command
args = ["--force"]
- args << @new_resource.svn_arguments << verbose << authentication <<
+ args << @new_resource.svn_arguments << verbose << authentication << proxy <<
"-r#{revision_int}" << @new_resource.repository << @new_resource.destination
c = scm :export, *args
Chef::Log.info "#{@new_resource} exported #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
@@ -194,6 +196,21 @@ class Chef
result
end
+ def proxy
+ %w{http https}.each { |p|
+ if @new_resource.repository.start_with?("#{p}:") &&
+ ENV["#{p}_proxy"] != nil &&
+ !fuzzy_hostname_match_any?(URI.parse(@new_resource.repository).host, ENV["no_proxy"])
+ proxy_uri = URI.parse(ENV["#{p}_proxy"])
+ result = "--config-option servers:global:http-proxy-host=#{proxy_uri.host} "
+ result << "--config-option servers:global:http-proxy-port=#{proxy_uri.port} "
+ return result
+ end
+ }
+
+ ""
+ end
+
def scm(*args)
binary = svn_binary
binary = "\"#{binary}\"" if binary =~ /\s/