summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-02-14 12:57:09 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-14 12:57:09 -0800
commitb10d17943f8b007f9adeebbd97c32fb606947607 (patch)
treeb4c17dd519efd66fe488a73f0f6fd8bd23c29fac /lib
parentf429544e076db4e63cc1bb193466cd883354ac1e (diff)
downloadchef-b10d17943f8b007f9adeebbd97c32fb606947607.tar.gz
coerce immutable arrays to normal arrayslcg/yum-coerce-array-attributes
as noted in comments this works around bugginess in the yum provider that require a major refactor to fix. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource/package.rb2
-rw-r--r--lib/chef/resource/yum_package.rb15
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb
index baaa5be2c8..a1f174a6f3 100644
--- a/lib/chef/resource/package.rb
+++ b/lib/chef/resource/package.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb
index 1e0ad197ba..2fc5db5cc3 100644
--- a/lib/chef/resource/yum_package.rb
+++ b/lib/chef/resource/yum_package.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,8 +24,17 @@ class Chef
resource_name :yum_package
provides :package, os: "linux", platform_family: %w{rhel fedora}
- # Install a specific arch
- property :arch, [ String, Array ]
+ # XXX: the coercions here are due to the provider promiscuously updating the properties on the
+ # new_resource which causes immutable modification exceptions when passed an immutable node array.
+ #
+ # <lecture>
+ # THIS is why updating the new_resource in a provider is so terrible, and is equivalent to methods scribbling over
+ # its own arguments as unintended side-effects (and why functional languages that don't allow modifcations
+ # of variables eliminate entire classes of bugs).
+ # </lecture>
+ property :package_name, [ String, Array ], identity: true, coerce: proc { |x| x.is_a?(Array) ? x.to_a : x }
+ property :version, [ String, Array ], coerce: proc { |x| x.is_a?(Array) ? x.to_a : x }
+ property :arch, [ String, Array ], coerce: proc { |x| x.is_a?(Array) ? x.to_a : x }
property :flush_cache,
Hash,