summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2013-05-28 14:52:43 -0700
committersersut <serdar@opscode.com>2013-05-30 13:44:50 -0700
commitaeee4bf96582769207780311b7b882c387656567 (patch)
tree7b4f639d6db0e6bafe17fd511d02239022a7a2e4
parentf5128d2290b5bb7646f97e61e246b7b09a848a1b (diff)
downloadchef-aeee4bf96582769207780311b7b882c387656567.tar.gz
Remove binmode property from file / remote_directory resources and always operate in binmode.
-rw-r--r--lib/chef/file_content_management/tempfile.rb4
-rw-r--r--lib/chef/provider/remote_directory.rb1
-rw-r--r--lib/chef/resource/file.rb9
-rw-r--r--lib/chef/resource/remote_directory.rb9
-rw-r--r--lib/chef/rest.rb2
-rw-r--r--spec/unit/provider/cron/solaris_spec.rb2
-rw-r--r--spec/unit/provider/file/content_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/ftp_spec.rb1
-rw-r--r--spec/unit/rest_spec.rb2
9 files changed, 7 insertions, 25 deletions
diff --git a/lib/chef/file_content_management/tempfile.rb b/lib/chef/file_content_management/tempfile.rb
index d109e3f51f..0bb7f3a6fa 100644
--- a/lib/chef/file_content_management/tempfile.rb
+++ b/lib/chef/file_content_management/tempfile.rb
@@ -36,7 +36,9 @@ class Chef
def tempfile_open
tf = ::Tempfile.open(tempfile_basename, tempfile_dirname)
- tf.binmode if new_resource.binmode
+ # We always process the tempfile in binmode so that we
+ # preserve the line endings of the content.
+ tf.binmode
tf
end
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index e7d0169c0f..129c5208f0 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -137,7 +137,6 @@ class Chef
cookbook_file.group(@new_resource.files_group) if @new_resource.files_group
cookbook_file.owner(@new_resource.files_owner) if @new_resource.files_owner
cookbook_file.backup(@new_resource.files_backup) if @new_resource.files_backup
- cookbook_file.binmode(@new_resource.files_binmode) if @new_resource.files_binmode
cookbook_file
end
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index 31b08e826d..43b7b21f2c 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -46,7 +46,6 @@ class Chef
@action = "create"
@allowed_actions.push(:create, :delete, :touch, :create_if_missing)
@provider = Chef::Provider::File
- @binmode = Platform.windows? ? true : false
@atomic_update = Chef::Config[:file_atomic_update]
@force_unlink = false
@diff = nil
@@ -93,14 +92,6 @@ class Chef
)
end
- def binmode(arg=nil)
- set_or_return(
- :binmode,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
def atomic_update(arg=nil)
set_or_return(
:atomic_update,
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
index 4aecde59b2..0f7e0eb5de 100644
--- a/lib/chef/resource/remote_directory.rb
+++ b/lib/chef/resource/remote_directory.rb
@@ -45,7 +45,6 @@ class Chef
@files_owner = nil
@files_group = nil
@files_mode = 0644 unless Chef::Platform.windows?
- @files_binmode = Platform.windows? ? true : false
@overwrite = true
@allowed_actions.push(:create, :create_if_missing, :delete)
@cookbook = nil
@@ -106,14 +105,6 @@ class Chef
)
end
- def files_binmode(arg=nil)
- set_or_return(
- :diff,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
def overwrite(arg=nil)
set_or_return(
:overwrite,
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
index 931f94ef79..37502d44e5 100644
--- a/lib/chef/rest.rb
+++ b/lib/chef/rest.rb
@@ -374,7 +374,7 @@ class Chef
def stream_to_tempfile(url, response)
tf = Tempfile.open("chef-rest")
if Chef::Platform.windows?
- tf.binmode #required for binary files on Windows platforms
+ tf.binmode # required for binary files on Windows platforms
end
Chef::Log.debug("Streaming download from #{url.to_s} to tempfile #{tf.path}")
# Stolen from http://www.ruby-forum.com/topic/166423
diff --git a/spec/unit/provider/cron/solaris_spec.rb b/spec/unit/provider/cron/solaris_spec.rb
index 55516d59e9..498d4fb1f5 100644
--- a/spec/unit/provider/cron/solaris_spec.rb
+++ b/spec/unit/provider/cron/solaris_spec.rb
@@ -87,7 +87,7 @@ CRONTAB
before :each do
@status = mock("Status", :exitstatus => 0)
@provider.stub!(:run_command).and_return(@status)
- @tempfile = mock("foo", :path => "/tmp/foo", :close => true, :binmode => nil)
+ @tempfile = mock("foo", :path => "/tmp/foo", :close => true)
Tempfile.stub!(:new).and_return(@tempfile)
@tempfile.should_receive(:flush)
@tempfile.should_receive(:chmod).with(420)
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb
index 1e681d5c15..693877760e 100644
--- a/spec/unit/provider/file/content_spec.rb
+++ b/spec/unit/provider/file/content_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Provider::File::Content do
}
let(:new_resource) do
- mock("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path, :binmode => true)
+ mock("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path)
end
let(:run_context) do
diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb
index 121fe1ed45..2d2e9d34cb 100644
--- a/spec/unit/provider/remote_file/ftp_spec.rb
+++ b/spec/unit/provider/remote_file/ftp_spec.rb
@@ -30,7 +30,6 @@ describe Chef::Provider::RemoteFile::FTP do
r = Chef::Resource::RemoteFile.new("remote file ftp backend test (new resource)")
r.ftp_active_mode(false)
r.path(resource_path)
- r.binmode(true)
r
end
diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb
index a1ee607eb3..87f6eb0456 100644
--- a/spec/unit/rest_spec.rb
+++ b/spec/unit/rest_spec.rb
@@ -497,7 +497,7 @@ describe Chef::REST do
it "closes and unlinks the tempfile when the response is a redirect" do
Tempfile.rspec_reset
- tempfile = mock("die", :path => "/tmp/ragefist", :close => true, :binmode => nil)
+ tempfile = mock("die", :path => "/tmp/ragefist", :close => true)
tempfile.should_receive(:close!).at_least(2).times
Tempfile.stub!(:new).with("chef-rest").and_return(tempfile)