From 1016e4e87d02d309b96bed99e7fb006a3aa958f4 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 15 Dec 2017 17:58:35 -0800 Subject: Fix bugs in handling 'source' in msu_package and cab_package The two issues fixed here: 1) cab_package did not require source, but didn't set it from the resource name so cab_package 'xyz.cab' would just fail since source was nil 2) msu_package would coerce the resource name and not package_name so if you overwrote the package name you would also have to set the source, although you wouldn't realize that until it failed oddly So the solution here is to set the source value to package_name by default and that gets coerced into a path as was previously done. This adds tests for this behavior and the coerce behavior itself to both resources. This fixes issue #6674 Signed-off-by: Tim Smith --- lib/chef/resource/cab_package.rb | 3 ++- lib/chef/resource/msu_package.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/chef/resource/cab_package.rb b/lib/chef/resource/cab_package.rb index 73e639814d..fcf3f02b86 100644 --- a/lib/chef/resource/cab_package.rb +++ b/lib/chef/resource/cab_package.rb @@ -34,7 +34,8 @@ class Chef unless s.nil? uri_scheme?(s) ? s : Chef::Util::PathHelper.canonical_path(s, false) end - end) + end), + default: lazy { |r| r.package_name } end end end diff --git a/lib/chef/resource/msu_package.rb b/lib/chef/resource/msu_package.rb index 65959c5621..93c8fbbe21 100644 --- a/lib/chef/resource/msu_package.rb +++ b/lib/chef/resource/msu_package.rb @@ -31,12 +31,12 @@ class Chef default_action :install property :source, String, - name_property: true, coerce: (proc do |s| unless s.nil? uri_scheme?(s) ? s : Chef::Util::PathHelper.canonical_path(s, false) end - end) + end), + default: lazy { |r| r.package_name } property :checksum, String, desired_state: false end end -- cgit v1.2.1