diff options
author | Bryan McLellan <btm@chef.io> | 2019-06-04 00:46:32 -0400 |
---|---|---|
committer | Bryan McLellan <btm@chef.io> | 2019-06-04 00:46:32 -0400 |
commit | 06662be51728188d982abe57fdcab35593fe4e9b (patch) | |
tree | b07621463768be0f37db2ac6ef9b50a5e811a769 | |
parent | 8ab574c75ada5112b89149cc63b3a4f007664974 (diff) | |
download | chef-06662be51728188d982abe57fdcab35593fe4e9b.tar.gz |
Create bootstrap template in binmode to fix line endings
Tempfile will create a file with CRLF on Windows, which when we upload to a
linux system then cannot be executed because of the line endings. Setting to
binmode prevents this.
Fixes chef/knife-ec2#580
Signed-off-by: Bryan McLellan <btm@chef.io>
-rw-r--r-- | lib/chef/knife/bootstrap/train_connector.rb | 1 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap/train_connector_spec.rb | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/lib/chef/knife/bootstrap/train_connector.rb index af09a8c366..a29581a51d 100644 --- a/lib/chef/knife/bootstrap/train_connector.rb +++ b/lib/chef/knife/bootstrap/train_connector.rb @@ -148,6 +148,7 @@ class Chef # @return NilClass def upload_file_content!(content, remote_path) t = Tempfile.new("chef-content") + t.binmode t << content t.close upload_file!(t.path, remote_path) diff --git a/spec/unit/knife/bootstrap/train_connector_spec.rb b/spec/unit/knife/bootstrap/train_connector_spec.rb index 385a192648..c3c559c65b 100644 --- a/spec/unit/knife/bootstrap/train_connector_spec.rb +++ b/spec/unit/knife/bootstrap/train_connector_spec.rb @@ -171,6 +171,7 @@ describe Chef::Knife::Bootstrap::TrainConnector do expect(File.read(local_path)).to eq "test data" expect(remote_path).to eq "/target/path" end + expect_any_instance_of(Tempfile).to receive(:binmode) subject.upload_file_content!("test data", "/target/path") end end |