summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/chocolatey.rb
diff options
context:
space:
mode:
authordheerajd-msys <dheeraj.dubey@msystechnologies.com>2017-09-25 18:33:25 +0530
committerdheerajd-msys <dheeraj.dubey@msystechnologies.com>2017-09-29 19:09:12 +0530
commit3e758a087301374f24f622b0c72fe1bbeb437cb2 (patch)
tree9ba0fe1124f2a7686dc814562dda774025b1f691 /lib/chef/provider/package/chocolatey.rb
parent7dbd6df0ba4060efe1a6086c990d77619d7a0d4f (diff)
downloadchef-3e758a087301374f24f622b0c72fe1bbeb437cb2.tar.gz
array support for choco pkg from artifactory
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
Diffstat (limited to 'lib/chef/provider/package/chocolatey.rb')
-rw-r--r--lib/chef/provider/package/chocolatey.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index a1ec4504a0..27b7420278 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -177,7 +177,13 @@ EOS
# @return [Array] list of candidate_version, same index as new_resource.package_name/version
def build_candidate_versions
new_resource.package_name.map do |package_name|
- available_packages[package_name.downcase]
+ if new_resource.source && new_resource.source.include?("artifactory") && package_name_array.length > 1
+ available_packages_from_artifactory[package_name.downcase]
+ elsif new_resource.source && new_resource.source.include?("artifactory") && package_name_array.length == 1
+ available_packages[package_name.downcase]
+ else
+ available_packages[package_name.downcase]
+ end
end
end
@@ -238,6 +244,25 @@ EOS
@available_packages
end
+ # Getting packages from Artifactory server and return as candidate
+ def available_packages_from_artifactory
+ return @available_packages_from_artifactory if @available_packages_from_artifactory
+ @available_packages_from_artifactory = {}
+ package_name_array.length.times do |item|
+ a =
+ begin
+ cmd = [ "list -r #{package_name_array[item]}" ]
+ cmd.push( "-source #{new_resource.source}" )
+ raw = parse_list_output(*cmd).first.each_slice(2).to_h
+ raw.keys.each_with_object({}) do |name, available|
+ available[name] = desired_name_versions[name] || raw[name]
+ end
+ end
+ @available_packages_from_artifactory.merge! a
+ end
+ @available_packages_from_artifactory
+ end
+
# Installed packages in chocolatey as a Hash of names mapped to versions
# (names are downcased for case-insensitive matching)
#