diff options
Diffstat (limited to 'lib/chef/cookbook_uploader.rb')
-rw-r--r-- | lib/chef/cookbook_uploader.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb index a9f255df43..e409d78d30 100644 --- a/lib/chef/cookbook_uploader.rb +++ b/lib/chef/cookbook_uploader.rb @@ -13,7 +13,6 @@ require "chef/server_api" class Chef class CookbookUploader - attr_reader :cookbooks attr_reader :path attr_reader :opts @@ -37,7 +36,7 @@ class Chef # in Chef::Config. # * :concurrency An integer that decided how many threads will be used to # perform concurrent uploads - def initialize(cookbooks, opts={}) + def initialize(cookbooks, opts = {}) @opts = opts @cookbooks = Array(cookbooks) @rest = opts[:rest] || Chef::ServerAPI.new(Chef::Config[:chef_server_url]) @@ -55,7 +54,7 @@ class Chef checksum_files.merge!(cb.checksums) end - checksums = checksum_files.inject({}){|memo,elt| memo[elt.first]=nil ; memo} + checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil ; memo } new_sandbox = rest.post("sandboxes", { :checksums => checksums }) Chef::Log.info("Uploading files") @@ -83,7 +82,7 @@ class Chef # in eventual consistency) retries = 0 begin - rest.put(sandbox_url, {:is_completed => true}) + rest.put(sandbox_url, { :is_completed => true }) rescue Net::HTTPServerException => e if e.message =~ /^400/ && (retries += 1) <= 5 sleep 2 @@ -95,7 +94,6 @@ class Chef # files are uploaded, so save the manifest cookbooks.each do |cb| - manifest = Chef::CookbookManifest.new(cb, policy_mode: policy_mode?) save_url = opts[:force] ? manifest.force_save_url : manifest.save_url @@ -120,7 +118,7 @@ class Chef # but we need the base64 encoding for the content-md5 # header checksum64 = Base64.encode64([checksum].pack("H*")).strip - file_contents = File.open(file, "rb") {|f| f.read} + file_contents = File.open(file, "rb") { |f| f.read } # Custom headers. 'content-type' disables JSON serialization of the request body. headers = { "content-type" => "application/x-binary", "content-md5" => checksum64, "accept" => "application/json" } @@ -152,6 +150,5 @@ class Chef def policy_mode? @policy_mode end - end end |