diff options
author | Thom May <thom@chef.io> | 2016-05-20 10:38:11 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-05-20 10:38:11 +0100 |
commit | 3a854109bd0de5fbac8faff7eab0a54e44d7881e (patch) | |
tree | 1bb8c031df172bec61c0ffcbbeec5032d1f91352 | |
parent | cfab6de01fd596a03b60ce9c9dd59e4b7cb5aa48 (diff) | |
download | chef-3a854109bd0de5fbac8faff7eab0a54e44d7881e.tar.gz |
Ensure recipe-url works right in solotm/solo_fixes
Signed-off-by: Thom May <thom@chef.io>
-rw-r--r-- | lib/chef/application/solo.rb | 10 | ||||
-rw-r--r-- | spec/unit/application/solo_spec.rb | 25 |
2 files changed, 34 insertions, 1 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index bc2d279508..9c34d613d8 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) |