summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-06-23 09:38:22 -0700
committerGitHub <noreply@github.com>2020-06-23 09:38:22 -0700
commit778b2737a4b9787c3190294f7d9c9cc092bd2b93 (patch)
tree2d70067acfcc6dbc6f5a5c538a25091dd452b05d
parenta34fd84377c705fcdf3a415b40300e11c3cacf35 (diff)
parentd9afa88bd5f377930008840c7010151e44152c79 (diff)
downloadchef-778b2737a4b9787c3190294f7d9c9cc092bd2b93.tar.gz
Merge pull request #10038 from chef/archive_file_15
archive_file: better handle mode property and deprecate Integer values
-rw-r--r--lib/chef/deprecated.rb8
-rw-r--r--lib/chef/resource/archive_file.rb5
-rw-r--r--spec/unit/resource/archive_file_spec.rb13
3 files changed, 22 insertions, 4 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 7962e96bfb..d67cee8153 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -233,6 +233,14 @@ class Chef
target 28
end
+ class KnifeBootstrapApis < Base
+ target 29
+ end
+
+ class ArchiveFileIntegerFileMode < Base
+ target 30
+ end
+
class Generic < Base
def url
"https://docs.chef.io/chef_deprecations_client/"
diff --git a/lib/chef/resource/archive_file.rb b/lib/chef/resource/archive_file.rb
index b4eed51137..6a5c57c679 100644
--- a/lib/chef/resource/archive_file.rb
+++ b/lib/chef/resource/archive_file.rb
@@ -65,7 +65,7 @@ class Chef
description: "The group of the extracted files."
property :mode, [String, Integer],
- description: "The mode of the extracted files.",
+ description: "The mode of the extracted files. Integer values are deprecated as octal values (ex. 0755) would not be interpreted correctly.",
default: "755"
property :destination, String,
@@ -97,7 +97,8 @@ class Chef
Chef::Log.trace("File or directory does not exist at destination path: #{new_resource.destination}")
converge_by("create directory #{new_resource.destination}") do
- FileUtils.mkdir_p(new_resource.destination, mode: new_resource.mode.to_i)
+ # @todo when we remove the ability for mode to be an int we can remove the .to_s below
+ FileUtils.mkdir_p(new_resource.destination, mode: new_resource.mode.to_s.to_i(8))
end
extract(new_resource.path, new_resource.destination, Array(new_resource.options))
diff --git a/spec/unit/resource/archive_file_spec.rb b/spec/unit/resource/archive_file_spec.rb
index 5e44284b66..6effe550db 100644
--- a/spec/unit/resource/archive_file_spec.rb
+++ b/spec/unit/resource/archive_file_spec.rb
@@ -18,8 +18,11 @@
require "spec_helper"
describe Chef::Resource::ArchiveFile do
-
- let(:resource) { Chef::Resource::ArchiveFile.new("foo") }
+ let(:node) { Chef::Node.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:resource) { Chef::Resource::ArchiveFile.new("foo", run_context) }
+ let(:provider) { resource.provider_for_action(:extract) }
it "has a resource name of :archive_file" do
expect(resource.resource_name).to eql(:archive_file)
@@ -41,6 +44,12 @@ describe Chef::Resource::ArchiveFile do
expect(resource.mode).to eql("755")
end
+ it "mode property throws a deprecation warning if Integers are passed" do
+ expect(Chef::Log).to receive(:deprecation)
+ resource.mode 755
+ provider.define_resource_requirements
+ end
+
it "options property defaults to [:time]" do
expect(resource.options).to eql([:time])
end