From 1b3705ca383b64092c9ef54d7e46201fab6271c7 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 8 Dec 2014 13:44:59 -0800 Subject: Execute and Script Resource improvements - Warning on incorrect usage of the command resource in any script resource - Warning on code in script resource being nil - Specs added to force deprecation of incorrect usage in Chef-13 - Specs added around the (supported) incorrect usage in Chef-12 - Cleanup+Modernization of providers and specs - Fixed some global state bugs around the Chef::Log.level in the spec tests --- lib/chef/resource/execute.rb | 14 +++++++------- lib/chef/resource/script.rb | 11 +++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'lib/chef/resource') diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 980035b079..dfae88b24e 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -106,7 +106,7 @@ class Chef set_or_return( :timeout, arg, - :kind_of => [ Integer ] + :kind_of => [ Integer, Float ] ) end @@ -135,12 +135,12 @@ class Chef end set_guard_inherited_attributes( - :cwd, - :environment, - :group, - :user, - :umask - ) + :cwd, + :environment, + :group, + :user, + :umask + ) end end diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb index 479295922c..fd0fd5a7fd 100644 --- a/lib/chef/resource/script.rb +++ b/lib/chef/resource/script.rb @@ -24,11 +24,13 @@ class Chef class Resource class Script < Chef::Resource::Execute + # Chef-13: go back to using :name as the identity attr identity_attr :command def initialize(name, run_context=nil) super @resource_name = :script + # Chef-13: the command variable should be initialized to nil @command = name @code = nil @interpreter = nil @@ -36,6 +38,15 @@ class Chef @default_guard_interpreter = :default end + def command(arg=nil) + unless arg.nil? + # Chef-13: change this to raise if the user is trying to set a value here + Chef::Log.warn "Specifying command attribute on a script resource is a coding error, use the 'code' attribute, or the execute resource" + Chef::Log.warn "This attribute is deprecated and must be fixed or this code will fail on Chef-13" + end + super + end + def code(arg=nil) set_or_return( :code, -- cgit v1.2.1