diff options
author | David Workman <workmad3@gmail.com> | 2014-09-03 23:49:36 +0100 |
---|---|---|
committer | David Workman <workmad3@gmail.com> | 2014-09-03 23:49:36 +0100 |
commit | 10621b23c26cd813cc8559d61105bf8be20e0c37 (patch) | |
tree | d98bd7f87d1e00ee4702ca01fba2342f1b038682 /lib/chef/application | |
parent | f1de2a538ba8b89bdcb24de168db0b99cb0cc8fb (diff) | |
download | chef-10621b23c26cd813cc8559d61105bf8be20e0c37.tar.gz |
Fixing case of a nil recipe file with chef apply
Raising the error 'No recipe file was provided' with a fatal!
call when the recipe_name is nil. This case occurs when
chef-apply is called without a recipe name argument.
Also renamed the apply spec file to apply_spec so it is picked
up by an rspec test run. Fixed a typo in the file where it was
creating a 'Chef::Application::Recipe' for @app instead of
'Chef::Application::Apply'
Diffstat (limited to 'lib/chef/application')
-rw-r--r-- | lib/chef/application/apply.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb index f2dd2cb586..7e5d5406c0 100644 --- a/lib/chef/application/apply.rb +++ b/lib/chef/application/apply.rb @@ -92,14 +92,18 @@ class Chef::Application::Apply < Chef::Application end def read_recipe_file(file_name) - recipe_path = file_name.to_s - unless File.exist?(recipe_path) - Chef::Application.fatal!("No file exists at #{recipe_path}", 1) + if file_name.nil? + Chef::Application.fatal!("No recipe file was provided", 1) + else + recipe_path = file_name + unless File.exist?(recipe_path) + Chef::Application.fatal!("No file exists at #{recipe_path}", 1) + end + recipe_path = File.expand_path(recipe_path) + recipe_fh = open(recipe_path) + recipe_text = recipe_fh.read + [recipe_text, recipe_fh] end - recipe_path = File.expand_path(recipe_path) - recipe_fh = open(recipe_path) - recipe_text = recipe_fh.read - [recipe_text, recipe_fh] end def get_recipe_and_run_context |