summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-02-26 16:05:26 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-28 11:19:49 -0800
commit8f2cdc75307dfba5d3867d0794dc6085795dc36f (patch)
tree94a1be6ab8507ba7a0e701b805e2d8539ec27c92
parent80547d21f52630d65a321975a6b9d19d9f2f49f4 (diff)
downloadchef-8f2cdc75307dfba5d3867d0794dc6085795dc36f.tar.gz
Chef-13: relative creates paths in the execute resource requires a cwd
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--RELEASE_NOTES.md5
-rw-r--r--lib/chef/exceptions.rb3
-rw-r--r--lib/chef/provider/execute.rb6
-rw-r--r--spec/unit/provider/execute_spec.rb16
4 files changed, 13 insertions, 17 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 6dd5c6edc5..374396ae9a 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -32,3 +32,8 @@ In order to for community cookbooks to behave consistently across all users this
The remediation is to set the manage_home and non_unique properties directly.
+### Using relative paths in the `creates` property of an execute resource with specifying a `cwd` is now a hard error
+
+Without a declared cwd the relative path was (most likely?) relative to wherever chef-client happened to be invoked which is
+not deterministic or easy to intuit behavior.
+
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index ae62f42b09..78bdf0cf4a 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Seth Falcon (<seth@chef.io>)
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
-# 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");
@@ -47,6 +47,7 @@ class Chef
class Cron < RuntimeError; end
class Env < RuntimeError; end
class Exec < RuntimeError; end
+ class Execute < RuntimeError; end
class ErlCall < RuntimeError; end
class FileNotFound < RuntimeError; end
class Package < RuntimeError; end
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index 28dce5d18c..81bfd25158 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@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");
@@ -39,9 +39,9 @@ class Chef
end
def define_resource_requirements
- # @todo: this should change to raise in some appropriate major version bump.
if creates && creates_relative? && !cwd
- Chef::Log.warn "Providing a relative path for the creates attribute without the cwd is deprecated and will be changed to fail in the future (CHEF-3819)"
+ # FIXME? move this onto the resource?
+ raise Chef::Exceptions::Execute, "Please either specify a full path for the creates attribute, or specify a cwd propoerty to the #{new_resource} resource"
end
end
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 1901e2ea03..904a2841c5 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Prajakta Purohit (<prajakta@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");
@@ -118,19 +118,9 @@ describe Chef::Provider::Execute do
new_resource.creates "foo_resource"
end
- it "should warn in Chef-12", chef: "< 13" do
- expect(Chef::Log).to receive(:warn).with(/relative path/)
- expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
+ it "should raise if user specified relative path without cwd for Chef-13" do
expect(provider).not_to receive(:shell_out!)
- provider.run_action(:run)
- expect(new_resource).not_to be_updated
- end
-
- it "should raise if user specified relative path without cwd for Chef-13", chef: ">= 13" do
- expect(Chef::Log).to receive(:warn).with(/relative path/)
- expect(FileTest).to receive(:exist?).with(new_resource.creates).and_return(true)
- expect(provider).not_to receive(:shell_out!)
- expect { provider.run_action(:run) }.to raise_error # @todo: add a real error for Chef-13
+ expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::Execute)
end
end