diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-06-05 09:44:26 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-06-05 09:44:26 -0700 |
commit | e15fddfb3b8dbf4cb613783b06f60a8c333bba96 (patch) | |
tree | 7e1d2f4201a14e5b65e9daf2c6e284e32ff36bf4 | |
parent | c15d7d0622e908bebaba6c1b84080c3cda521471 (diff) | |
download | chef-e15fddfb3b8dbf4cb613783b06f60a8c333bba96.tar.gz |
need to inject self
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/mixin/shell_out.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb index 6cacd46312..47d9d88971 100644 --- a/lib/chef/mixin/shell_out.rb +++ b/lib/chef/mixin/shell_out.rb @@ -62,7 +62,7 @@ class Chef # def shell_out_compact(*args, **options) - options = Chef::Mixin::ShellOut.maybe_add_timeout(options) + options = Chef::Mixin::ShellOut.maybe_add_timeout(self, options) if options.empty? shell_out(*clean_array(*args)) else @@ -71,7 +71,7 @@ class Chef end def shell_out_compact!(*args, **options) - options = Chef::Mixin::ShellOut.maybe_add_timeout(options) + options = Chef::Mixin::ShellOut.maybe_add_timeout(self, options) if options.empty? shell_out!(*clean_array(*args)) else @@ -79,12 +79,13 @@ class Chef end end + # module method to not pollute namespaces, but that means we need self injected as an arg # @api private - def self.maybe_add_timeout(options) - if is_a?(Chef::Provider) && !new_resource.is_a?(Chef::Resource::LWRPBase) && new_resource.respond_to?(:timeout) && !options.key?(:timeout) + def self.maybe_add_timeout(obj, options) + if obj.is_a?(Chef::Provider) && !obj.new_resource.is_a?(Chef::Resource::LWRPBase) && obj.new_resource.respond_to?(:timeout) && !options.key?(:timeout) options = options.dup # historically resources have not properly declared defaults on their timeouts, so a default default of 900s was enforced here - options[:timeout] = new_resource.timeout ? new_resource.timeout.to_f : 900 + options[:timeout] = obj.new_resource.timeout ? obj.new_resource.timeout.to_f : 900 end options end |