summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2020-03-18 20:18:00 -0400
committerBryan McLellan <btm@loftninjas.org>2020-03-23 12:57:09 -0400
commit97497d968b806727cfeb00fdef2ec3976fbd53d8 (patch)
tree53c177e0d47a0b3eeb551b25e2efb82be83a159f /lib
parentea801d898ba2a7a6e9bee6202710fab28ebf9e9a (diff)
downloadchef-97497d968b806727cfeb00fdef2ec3976fbd53d8.tar.gz
Simplify YAML mode checking for chef-apply
Signed-off-by: Bryan McLellan <btm@loftninjas.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/application/apply.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index e242f91d29..7267f4ecfa 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -154,10 +154,6 @@ class Chef::Application::Apply < Chef::Application
if file_name.nil?
Chef::Application.fatal!("No recipe file was provided", Chef::Exceptions::RecipeNotFound.new)
else
- if file_name =~ /\.yml$/
- logger.info "Recipe file name ends with .yml, parsing as YAML"
- config[:yaml] = true
- end
recipe_path = File.expand_path(file_name)
unless File.exist?(recipe_path)
Chef::Application.fatal!("No file exists at #{recipe_path}", Chef::Exceptions::RecipeNotFound.new)
@@ -208,7 +204,8 @@ class Chef::Application::Apply < Chef::Application
@recipe_text, @recipe_fh = read_recipe_file @recipe_filename
end
recipe, run_context = get_recipe_and_run_context
- if config[:yaml]
+ if config[:yaml] || File.extname(@recipe_filename) == ".yml"
+ logger.info "Parsing recipe as YAML"
recipe.from_yaml(@recipe_text)
else
recipe.instance_eval(@recipe_text, @recipe_filename, 1)