summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-05-31 18:25:55 +0100
committerThom May <thom@may.lt>2016-05-31 18:25:55 +0100
commitf620577c57c9282e3ccc71a29cefacfe939d6329 (patch)
tree7fb3c1f0146c08bb5019d388c42bc23569a8417e
parentd5249426a11ada942365160fcb3a64de0840a09c (diff)
parent3a854109bd0de5fbac8faff7eab0a54e44d7881e (diff)
downloadchef-f620577c57c9282e3ccc71a29cefacfe939d6329.tar.gz
Merge pull request #4957 from chef/tm/solo_fixes
Ensure recipe-url works right in solo
-rw-r--r--lib/chef/application/solo.rb10
-rw-r--r--spec/unit/application/solo_spec.rb25
2 files changed, 34 insertions, 1 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 0c66f6cf40..ecac3f4d4e 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -212,6 +212,7 @@ class Chef::Application::Solo < Chef::Application
def run
setup_signal_handlers
reconfigure
+ for_ezra if Chef::Config[:ez]
if !Chef::Config[:solo_legacy_mode]
Chef::Application::Client.new.run
else
@@ -232,6 +233,14 @@ class Chef::Application::Solo < Chef::Application
Chef::Log.deprecation("-r MUST be changed to --recipe-url, the -r option will be changed in Chef 13.0") if ARGV.include?("-r")
if !Chef::Config[:solo_legacy_mode]
+ # Because we re-parse ARGV when we move to chef-client, we need to tidy up some options first.
+ ARGV.delete("--ez")
+
+ # -r means something entirely different in chef-client land, so let's replace it with a "safe" value
+ if dash_r = ARGV.index("-r")
+ ARGV[dash_r] = "--recipe-url"
+ end
+
Chef::Config[:local_mode] = true
else
configure_legacy_mode!
@@ -277,7 +286,6 @@ class Chef::Application::Solo < Chef::Application
end
def run_application
- for_ezra if Chef::Config[:ez]
if !Chef::Config[:client_fork] || Chef::Config[:once]
# Run immediately without interval sleep or splay
begin
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 1c8ec2e11c..bb29261f5a 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -187,6 +187,31 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
expect(Chef::Config[:local_mode]).to be_truthy
end
+ context "argv gets tidied up" do
+ before do
+ @original_argv = ARGV.dup
+ ARGV.clear
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ end
+
+ after do
+ ARGV.replace(@original_argv)
+ end
+
+ it "deletes --ez" do
+ ARGV << "--ez"
+ app.reconfigure
+ expect(ARGV.include?("--ez")).to be_falsey
+ end
+
+ it "replaces -r with --recipe-url" do
+ ARGV.push("-r", "http://junglist.gen.nz/recipes.tgz")
+ app.reconfigure
+ expect(ARGV.include?("-r")).to be_falsey
+ expect(ARGV.include?("--recipe-url")).to be_truthy
+ end
+ end
+
it "runs chef-client in local mode" do
allow(app).to receive(:setup_application).and_return(true)
allow(app).to receive(:run_application).and_return(true)