diff options
Diffstat (limited to 'lib/chef/provider/subversion.rb')
-rw-r--r-- | lib/chef/provider/subversion.rb | 25 |
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/ |