summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-01-25 18:40:24 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-25 18:40:24 -0800
commita151dea58310b51fdcb7afa78171e7ab70044170 (patch)
treede9df5a7a957119a7dae24e3335040108fa4cc12
parent8a805c8a71a91cb17099acdc748f619eeba45efd (diff)
downloadchef-a151dea58310b51fdcb7afa78171e7ab70044170.tar.gz
fix master
broken by merging #2431. code was actually broken and the specs were broken, not sure how it got into ready-to-merge in that state. rolled back the FileUtils.rm_rf that was in the original patch since it trashed my chef git repo and in light of: https://github.com/ValveSoftware/steam-for-linux/issues/3671 i think the rm_rf is a bad idea.
-rw-r--r--lib/chef/application/client.rb4
-rw-r--r--spec/data/recipes.tgzbin4120 -> 293 bytes
-rw-r--r--spec/integration/client/client_spec.rb11
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 024a160315..c0635e1cb5 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -207,7 +207,7 @@ class Chef::Application::Client < Chef::Application
:boolean => true
option :recipe_url,
- :long => "--recipe-url",
+ :long => "--recipe-url=RECIPE_URL",
:description => "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode."
option :enable_reporting,
@@ -276,8 +276,6 @@ class Chef::Application::Client < Chef::Application
if !Chef::Config.local_mode && Chef::Config.has_key?(:recipe_url)
Chef::Application.fatal!("chef-client recipe-url can be used only in local-mode", 1)
elsif Chef::Config.local_mode && Chef::Config.has_key?(:recipe_url)
- Chef::Log.debug "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it"
- FileUtils.rm_rf(Chef::Config.chef_repo_path, :secure => true)
Chef::Log.debug "Creating path #{Chef::Config.chef_repo_path} to extract recipes into"
FileUtils.mkdir_p(Chef::Config.chef_repo_path)
tarball_path = File.join(Chef::Config.chef_repo_path, 'recipes.tgz')
diff --git a/spec/data/recipes.tgz b/spec/data/recipes.tgz
index e5d3e1669a..a6c172a001 100644
--- a/spec/data/recipes.tgz
+++ b/spec/data/recipes.tgz
Binary files differ
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 880e9c55d8..3475a569b6 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -1,5 +1,7 @@
require 'support/shared/integration/integration_helper'
require 'chef/mixin/shell_out'
+require 'tiny_server'
+require 'tmpdir'
def recipes_filename
File.join(CHEF_SPEC_DATA, 'recipes.tgz')
@@ -315,17 +317,18 @@ end
stop_tiny_server
end
+ let(:tmp_dir) { Dir.mktmpdir("recipe-url") }
+
it "should complete with success when passed -z and --recipe-url" do
file 'config/client.rb', <<EOM
-cookbook_path "#{path_to('cookbooks')}"
+chef_repo_path "#{tmp_dir}"
EOM
-
- result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => chef_dir)
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => tmp_dir)
result.error!
end
it 'should fail when passed --recipe-url and not passed -z' do
- result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", :cwd => chef_dir)
+ result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", :cwd => tmp_dir)
expect(result.exitstatus).to eq(1)
end
end