diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-17 18:04:28 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-17 18:05:06 -0800 |
commit | 4e292e9c40b396c370ede42d49c75a7d20981e73 (patch) | |
tree | 436a05cc769a0f56d0ae438a79aefea4b2be2209 /lib/chef/resource/windows_package.rb | |
parent | 0e9c4382e9d58fbcf53ed67043b8de0bda01da21 (diff) | |
download | chef-4e292e9c40b396c370ede42d49c75a7d20981e73.tar.gz |
base package provider fixes
* removes the mutation of the new_resource.version
* adds package_class_supports_arrays for multipackage providers
* cleans up the package resource initializer and sets the package_name
correctly through the accessor method.
By mutating new_resource.version we were destroying the original intent
of what the user was requesting. This is a bug that must be fixed.
Generally, subclasses will be able to get the correct information they
need through either the version argument they were passed in
install_package(name, version) instead, or through their
`#target_version_array` method. If this breaks anything then those
providers need bugfixes as well (since this is a change to an internal
API accessible only to subclassing, and there are backwards compatible
and correct ways to get the information, this is *not* a SemVer
violating change). See the fix I made to the OpenBSD provider to
preserve the same semantics, avoid using new_resource.version where it
was inappropriate, and make the code more symmetrical where before
substantially different looking code in install_package and
remove_package had exactly the same ultimate effect.
The package_class_supports_arrays 'DSL' for writing multipackage
providers coerces the arguments to the virtual methods (e.g.
install_package) into arrays, even if the user is only requesting a
single package install. This removes most of the `is_a?(Array)`
checks from the implementation subclasses.
The cleanup of the initializer is similarly necessary so that we can
use Chef 12.5 coercions to make the package_name and version arguments
accept string, but always be Arrays. This should eliminate the rest
of the need to write `is_a?(Array)` code all over the package provider
implementations.
Diffstat (limited to 'lib/chef/resource/windows_package.rb')
-rw-r--r-- | lib/chef/resource/windows_package.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index a76765cc36..f11b7b8b3b 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -67,7 +67,7 @@ class Chef end def source(arg=nil) - if arg == nil && self.instance_variable_defined?(:@source) == true + if arg == nil @source else raise ArgumentError, "Bad type for WindowsPackage resource, use a String" unless arg.is_a?(String) |