From 5d023cb90fd04dca63465e2afa2886afd15a70f6 Mon Sep 17 00:00:00 2001 From: Bryan McLellan Date: Wed, 9 Jul 2014 17:45:41 -0400 Subject: CHEF-5075: order matters for recipe_url Add a test to ensure we maintain the order of fetching the tarball before loading JSON attributes from a file that may be in that recipe tarball Refactor slightly for the benefit of testing --- lib/chef/application/solo.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'lib/chef/application/solo.rb') diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index a55882bef1..f0e578d5ef 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -190,14 +190,10 @@ class Chef::Application::Solo < Chef::Application recipes_path = File.expand_path(File.join(cookbooks_path, '..')) Chef::Log.debug "Creating path #{recipes_path} to extract recipes into" - FileUtils.mkdir_p recipes_path - path = File.join(recipes_path, 'recipes.tgz') - File.open(path, 'wb') do |f| - open(Chef::Config[:recipe_url]) do |r| - f.write(r.read) - end - end - Chef::Mixin::Command.run_command(:command => "tar zxvf #{path} -C #{recipes_path}") + FileUtils.mkdir_p(recipes_path) + tarball_path = File.join(recipes_path, 'recipes.tgz') + fetch_recipe_tarball(Chef::Config[:recipe_url], tarball_path) + Chef::Mixin::Command.run_command(:command => "tar zxvf #{tarball_path} -C #{recipes_path}") end # json_attribs shuld be fetched after recipe_url tarball is unpacked. @@ -248,4 +244,14 @@ class Chef::Application::Solo < Chef::Application end end + private + + def fetch_recipe_tarball(url, path) + Chef::Log.debug("Download recipes tarball from #{url} to #{path}") + File.open(path, 'wb') do |f| + open(url) do |r| + f.write(r.read) + end + end + end end -- cgit v1.2.1