summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-12-08 14:54:58 -0800
committerSerdar Sutay <serdar@opscode.com>2014-12-08 15:48:09 -0800
commit7f760f67d178c050a521b6c0ead38fa1cec0eeee (patch)
tree2465408bf51796ab67ca3805f5b8a96c3d9c6e53
parentd65d1c2879025a5648c7cea03c3798cf8bb4bd94 (diff)
downloadchef-7f760f67d178c050a521b6c0ead38fa1cec0eeee.tar.gz
28fd0c9c87c6fceb7068776a04c32cd8381fe8f6 removed the path attribute from
execute resource. Even tough this attribute is not being honored by any provider, some existing cookbooks are still depending on this attribute. Restore path attribute in execute resource with a deprecation message that it will be removed in Chef 13.
-rw-r--r--lib/chef/resource/execute.rb11
-rw-r--r--spec/support/shared/unit/execute_resource.rb10
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index dfae88b24e..6853b62887 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -36,6 +36,7 @@ class Chef
@cwd = nil
@environment = nil
@group = nil
+ @path = nil
@returns = 0
@timeout = nil
@user = nil
@@ -94,6 +95,16 @@ class Chef
)
end
+ def path(arg=nil)
+ Chef::Log.warn "'path' attribute of 'execute' is not used by any provider in Chef 11 and Chef 12. Use 'environment' attribute to configure 'PATH'. This attribute will be removed in Chef 13."
+
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => [ Array ]
+ )
+ end
+
def returns(arg=nil)
set_or_return(
:returns,
diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb
index d6fb88db5c..e969a2ebd5 100644
--- a/spec/support/shared/unit/execute_resource.rb
+++ b/spec/support/shared/unit/execute_resource.rb
@@ -76,6 +76,16 @@ shared_examples_for "an execute resource" do
expect(@resource.group).to eql(1)
end
+ it "should accept an array for the execution path in Chef-12 and log deprecation message", :chef_lt_13_only do
+ expect(Chef::Log).to receive(:warn).at_least(:once)
+ @resource.path ["woot"]
+ expect(@resource.path).to eql(["woot"])
+ end
+
+ it "should raise an exception in chef-13", :chef_gte_13_only do
+ expect(@resource.path [ "woot" ]).to raise_error
+ end
+
it "should accept an integer for the return code" do
@resource.returns 1
expect(@resource.returns).to eql(1)