diff options
author | Bryan McLellan <btm@loftninjas.org> | 2014-07-09 17:45:41 -0400 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2014-08-29 08:01:47 -0400 |
commit | 5d023cb90fd04dca63465e2afa2886afd15a70f6 (patch) | |
tree | aa701055461342d46f451773ddf013f35efe344f /lib/chef/application/solo.rb | |
parent | 0679cf742c50bc4381b98a9d1b6820c024e524da (diff) | |
download | chef-5d023cb90fd04dca63465e2afa2886afd15a70f6.tar.gz |
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
Diffstat (limited to 'lib/chef/application/solo.rb')
-rw-r--r-- | lib/chef/application/solo.rb | 22 |
1 files changed, 14 insertions, 8 deletions
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 |