diff options
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rw-r--r-- | Gemfile.lock | 14 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | chef-bin/lib/chef-bin/version.rb | 2 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/command_line.rb | 23 | ||||
-rw-r--r-- | lib/chef/run_context/cookbook_compiler.rb | 23 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 | ||||
-rw-r--r-- | spec/data/run_context/cookbooks/dependency1/attributes/unparsed_file | 1 | ||||
-rw-r--r-- | spec/data/run_context/cookbooks/dependency1/definitions/unparsed_file | 1 | ||||
-rw-r--r-- | spec/data/run_context/cookbooks/dependency1/libraries/unparsed_file | 1 | ||||
-rw-r--r-- | spec/data/run_context/cookbooks/dependency1/providers/unparsed_file | 1 | ||||
-rw-r--r-- | spec/data/run_context/cookbooks/dependency1/recipes/unparsed_file | 1 | ||||
-rw-r--r-- | spec/data/run_context/cookbooks/dependency1/resources/unparsed_file | 1 | ||||
-rw-r--r-- | spec/unit/run_context/cookbook_compiler_spec.rb | 10 |
15 files changed, 53 insertions, 39 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 36a013d53c..7b2f9a2589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,17 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> -<!-- latest_release 15.0.258 --> -## [v15.0.258](https://github.com/chef/chef/tree/v15.0.258) (2019-05-03) +<!-- latest_release 15.0.260 --> +## [v15.0.260](https://github.com/chef/chef/tree/v15.0.260) (2019-05-06) #### Merged Pull Requests -- Update more brand names to current [#8454](https://github.com/chef/chef/pull/8454) ([tas50](https://github.com/tas50)) +- Resolve exceptions when running knife diff [#8459](https://github.com/chef/chef/pull/8459) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- latest_release --> <!-- release_rollup --> ### Changes since latest stable release #### Merged Pull Requests +- Resolve exceptions when running knife diff [#8459](https://github.com/chef/chef/pull/8459) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 15.0.260 --> +- Chef-15: cookbook compiler should parse only .rb files [#8456](https://github.com/chef/chef/pull/8456) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 15.0.259 --> - Update more brand names to current [#8454](https://github.com/chef/chef/pull/8454) ([tas50](https://github.com/tas50)) <!-- 15.0.258 --> - Add connstant for Chef Server and improve help messaging [#8452](https://github.com/chef/chef/pull/8452) ([tas50](https://github.com/tas50)) <!-- 15.0.257 --> - Fixed empty value for knife status long output [#8415](https://github.com/chef/chef/pull/8415) ([vijaymmali1990](https://github.com/vijaymmali1990)) <!-- 15.0.256 --> diff --git a/Gemfile.lock b/Gemfile.lock index fe19f48313..dba355adba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,11 +27,11 @@ GIT PATH remote: . specs: - chef (15.0.258) + chef (15.0.260) addressable bcrypt_pbkdf (~> 1.0) bundler (>= 1.10) - chef-config (= 15.0.258) + chef-config (= 15.0.260) chef-zero (>= 14.0.11) diff-lcs (~> 1.2, >= 1.2.4) ed25519 (~> 1.2) @@ -56,11 +56,11 @@ PATH train-core (~> 2.0, >= 2.0.12) tty-screen (~> 0.6) uuidtools (~> 2.1.5) - chef (15.0.258-universal-mingw32) + chef (15.0.260-universal-mingw32) addressable bcrypt_pbkdf (~> 1.0) bundler (>= 1.10) - chef-config (= 15.0.258) + chef-config (= 15.0.260) chef-zero (>= 14.0.11) diff-lcs (~> 1.2, >= 1.2.4) ed25519 (~> 1.2) @@ -101,13 +101,13 @@ PATH PATH remote: chef-bin specs: - chef-bin (15.0.258) - chef (= 15.0.258) + chef-bin (15.0.260) + chef (= 15.0.260) PATH remote: chef-config specs: - chef-config (15.0.258) + chef-config (15.0.260) addressable fuzzyurl mixlib-config (>= 2.2.12, < 4.0) @@ -1 +1 @@ -15.0.258
\ No newline at end of file +15.0.260
\ No newline at end of file diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb index 23420a3a29..6392b1232d 100644 --- a/chef-bin/lib/chef-bin/version.rb +++ b/chef-bin/lib/chef-bin/version.rb @@ -21,7 +21,7 @@ module ChefBin CHEFBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "15.0.258".freeze + VERSION = "15.0.260".freeze end # diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 6224865210..3aeb807e42 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -21,7 +21,7 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "15.0.258".freeze + VERSION = "15.0.260".freeze end # diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb index 5f449bad04..a61c68ceda 100644 --- a/lib/chef/chef_fs/command_line.rb +++ b/lib/chef/chef_fs/command_line.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. +# Copyright:: Copyright 2012-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -271,19 +271,18 @@ class Chef new_tempfile.write(new_value) new_tempfile.close - begin - old_tempfile = Tempfile.new("old") - old_tempfile.write(old_value) - old_tempfile.close + old_tempfile = Tempfile.new("old") + old_tempfile.write(old_value) + old_tempfile.close - result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path) - result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}") - result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}") - result - ensure - old_tempfile.close! - end + result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path) + result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}") + result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}") + result + rescue => e + "!!! Unable to diff #{old_path} and #{new_path} due to #{e}" ensure + old_tempfile.close! new_tempfile.close! end end diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb index 1bd612e721..1469462e69 100644 --- a/lib/chef/run_context/cookbook_compiler.rb +++ b/lib/chef/run_context/cookbook_compiler.rb @@ -206,13 +206,13 @@ class Chef end list_of_attr_files.each do |filename| + next unless File.extname(filename) == ".rb" load_attribute_file(cookbook_name.to_s, filename) end end def load_attribute_file(cookbook_name, filename) - # FIXME(log): should be trace - logger.debug("Node #{node.name} loading cookbook #{cookbook_name}'s attribute file #{filename}") + logger.trace("Node #{node.name} loading cookbook #{cookbook_name}'s attribute file #{filename}") attr_file_basename = ::File.basename(filename, ".rb") node.include_attribute("#{cookbook_name}::#{attr_file_basename}") rescue Exception => e @@ -224,8 +224,7 @@ class Chef files_in_cookbook_by_segment(cookbook_name, :libraries).each do |filename| next unless File.extname(filename) == ".rb" begin - # FIXME(log): should be trace - logger.debug("Loading cookbook #{cookbook_name}'s library file: #{filename}") + logger.trace("Loading cookbook #{cookbook_name}'s library file: #{filename}") Kernel.require(filename) @events.library_file_loaded(filename) rescue Exception => e @@ -237,16 +236,17 @@ class Chef def load_lwrps_from_cookbook(cookbook_name) files_in_cookbook_by_segment(cookbook_name, :providers).each do |filename| + next unless File.extname(filename) == ".rb" load_lwrp_provider(cookbook_name, filename) end files_in_cookbook_by_segment(cookbook_name, :resources).each do |filename| + next unless File.extname(filename) == ".rb" load_lwrp_resource(cookbook_name, filename) end end def load_lwrp_provider(cookbook_name, filename) - # FIXME(log): should be trace - logger.debug("Loading cookbook #{cookbook_name}'s providers from #{filename}") + logger.trace("Loading cookbook #{cookbook_name}'s providers from #{filename}") Chef::Provider::LWRPBase.build_from_file(cookbook_name, filename, self) @events.lwrp_file_loaded(filename) rescue Exception => e @@ -255,8 +255,7 @@ class Chef end def load_lwrp_resource(cookbook_name, filename) - # FIXME(log): should be trace - logger.debug("Loading cookbook #{cookbook_name}'s resources from #{filename}") + logger.trace("Loading cookbook #{cookbook_name}'s resources from #{filename}") Chef::Resource::LWRPBase.build_from_file(cookbook_name, filename, self) @events.lwrp_file_loaded(filename) rescue Exception => e @@ -269,8 +268,7 @@ class Chef files_in_cookbook_by_segment(cookbook_name, :ohai).each do |filename| next unless File.extname(filename) == ".rb" - # FIXME(log): should be trace - logger.debug "Loading Ohai plugin: #{filename} from #{cookbook_name}" + logger.trace "Loading Ohai plugin: #{filename} from #{cookbook_name}" target_name = File.join(target, cookbook_name.to_s, File.basename(filename)) FileUtils.mkdir_p(File.dirname(target_name)) @@ -280,9 +278,10 @@ class Chef def load_resource_definitions_from_cookbook(cookbook_name) files_in_cookbook_by_segment(cookbook_name, :definitions).each do |filename| + next unless File.extname(filename) == ".rb" + begin - # FIXME(log): should be trace - logger.debug("Loading cookbook #{cookbook_name}'s definitions from #{filename}") + logger.trace("Loading cookbook #{cookbook_name}'s definitions from #{filename}") resourcelist = Chef::ResourceDefinitionList.new resourcelist.from_file(filename) definitions.merge!(resourcelist.defines) do |key, oldval, newval| diff --git a/lib/chef/version.rb b/lib/chef/version.rb index 49a19d1014..793f70f4d9 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require "chef/version_string" class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = Chef::VersionString.new("15.0.258") + VERSION = Chef::VersionString.new("15.0.260") end # diff --git a/spec/data/run_context/cookbooks/dependency1/attributes/unparsed_file b/spec/data/run_context/cookbooks/dependency1/attributes/unparsed_file new file mode 100644 index 0000000000..60fee07cc6 --- /dev/null +++ b/spec/data/run_context/cookbooks/dependency1/attributes/unparsed_file @@ -0,0 +1 @@ +raise "this should not be parsed by the loader" diff --git a/spec/data/run_context/cookbooks/dependency1/definitions/unparsed_file b/spec/data/run_context/cookbooks/dependency1/definitions/unparsed_file new file mode 100644 index 0000000000..60fee07cc6 --- /dev/null +++ b/spec/data/run_context/cookbooks/dependency1/definitions/unparsed_file @@ -0,0 +1 @@ +raise "this should not be parsed by the loader" diff --git a/spec/data/run_context/cookbooks/dependency1/libraries/unparsed_file b/spec/data/run_context/cookbooks/dependency1/libraries/unparsed_file new file mode 100644 index 0000000000..60fee07cc6 --- /dev/null +++ b/spec/data/run_context/cookbooks/dependency1/libraries/unparsed_file @@ -0,0 +1 @@ +raise "this should not be parsed by the loader" diff --git a/spec/data/run_context/cookbooks/dependency1/providers/unparsed_file b/spec/data/run_context/cookbooks/dependency1/providers/unparsed_file new file mode 100644 index 0000000000..60fee07cc6 --- /dev/null +++ b/spec/data/run_context/cookbooks/dependency1/providers/unparsed_file @@ -0,0 +1 @@ +raise "this should not be parsed by the loader" diff --git a/spec/data/run_context/cookbooks/dependency1/recipes/unparsed_file b/spec/data/run_context/cookbooks/dependency1/recipes/unparsed_file new file mode 100644 index 0000000000..60fee07cc6 --- /dev/null +++ b/spec/data/run_context/cookbooks/dependency1/recipes/unparsed_file @@ -0,0 +1 @@ +raise "this should not be parsed by the loader" diff --git a/spec/data/run_context/cookbooks/dependency1/resources/unparsed_file b/spec/data/run_context/cookbooks/dependency1/resources/unparsed_file new file mode 100644 index 0000000000..60fee07cc6 --- /dev/null +++ b/spec/data/run_context/cookbooks/dependency1/resources/unparsed_file @@ -0,0 +1 @@ +raise "this should not be parsed by the loader" diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb index c3a4c1b98f..3c585cf444 100644 --- a/spec/unit/run_context/cookbook_compiler_spec.rb +++ b/spec/unit/run_context/cookbook_compiler_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2012-2018, Chef Software Inc. +# Copyright:: Copyright 2012-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -51,6 +51,14 @@ describe Chef::RunContext::CookbookCompiler do Chef::RunContext::CookbookCompiler.new(run_context, run_list_expansion, events) end + describe "loading a cookbook fully" do + it "does not error" do + run_context.instance_variable_set(:@cookbook_compiler, compiler) + node.run_list("dependency1::default") + compiler.compile + end + end + describe "loading attribute files" do # Attribute files in the fixture data will append their |