diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-04-30 15:00:12 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-05-15 07:04:16 -0700 |
commit | f2a512109482caeb7a553f2002cb18467da30136 (patch) | |
tree | 29d14f43f2e4ac4be9fcfc57d45cb4a89da150f0 /lib/chef/resource | |
parent | b086721ca70750277c407fd0cc573a08f076649f (diff) | |
download | chef-f2a512109482caeb7a553f2002cb18467da30136.tar.gz |
Modify windows package provider to allow url
Diffstat (limited to 'lib/chef/resource')
-rw-r--r-- | lib/chef/resource/windows_package.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index 16cfcf865e..de4f2573d4 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -69,10 +69,26 @@ class Chef @source else raise ArgumentError, "Bad type for WindowsPackage resource, use a String" unless arg.is_a?(String) - Chef::Log.debug("#{package_name}: sanitizing source path '#{arg}'") - @source = ::File.absolute_path(arg).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR) + if is_url?(arg) + @source = arg + else + @source = ::File.absolute_path(arg).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR) + end end end + + private + + def is_url?(source) + begin + scheme = URI.split(source).first + return false unless scheme + %w(http https ftp file).include?(scheme.downcase) + rescue URI::InvalidURIError + return false + end + end + end end end |