summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-12-08 18:38:26 -0800
committerSerdar Sutay <serdar@opscode.com>2014-12-08 18:40:12 -0800
commitbc87ec6ecf8eae8ec13a64b97dc1da551b516497 (patch)
tree1d0044ef4dd8d903adda43a49d732fa18dc52d57
parenta5a032186b2c1ba360f82f2c71ef013e80a67b99 (diff)
downloadchef-bc87ec6ecf8eae8ec13a64b97dc1da551b516497.tar.gz
Merge pull request #2571 from opscode/sersut/restore-path
Restore path attribute in execute resource with deprecation warning Conflicts: CHANGELOG.md
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/chef/resource/execute.rb11
-rw-r--r--spec/support/shared/unit/execute_resource.rb10
3 files changed, 22 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 721a992f5d..5928d7bf90 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 12.0.1
* [Issue 2552](https://github.com/opscode/chef/issues/2552) Create constant for LWRP before calling `provides`
+* [Issue 2545](https://github.com/opscode/chef/issues/2545) `path` attribute of `execute` resource is restored to provide backwards compatibility with Chef 11.
## 12.0.0
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 980035b079..4fbaaf93ab 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 298e0c5baf..5d901ecf57 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
@resource.group.should 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
@resource.returns.should eql(1)