diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-09-27 16:48:36 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-10-28 14:06:22 +0530 |
commit | f725ddcc52bd7ca5cf3b7ac1ba87778e4c4e39a2 (patch) | |
tree | 4897a2672b443308fcd3855c98a8ef4c2002ef24 | |
parent | 377861d1f1dcd93f39f1e8596db50a63f7650ca2 (diff) | |
download | chef-f725ddcc52bd7ca5cf3b7ac1ba87778e4c4e39a2.tar.gz |
Fix knife cookbook site share chefignore lookup
Fix cookbook syntax_check dir path error if cookbook_path is an array
Fix invalid error if cookbook_path set to nil or empty Array and TypeError: no implicit conversion of nil into String
Chefignore for each cookbooks/:cookbook
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r-- | lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb | 7 | ||||
-rw-r--r-- | lib/chef/cookbook/chefignore.rb | 2 | ||||
-rw-r--r-- | lib/chef/cookbook/syntax_check.rb | 8 | ||||
-rw-r--r-- | lib/chef/cookbook_loader.rb | 6 |
4 files changed, 12 insertions, 11 deletions
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb index 1708428372..6ae5045284 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb @@ -68,13 +68,14 @@ class Chef end # Check chefignore - ignorer = parent + ignorer = self + loop do - if ignorer.is_a?(CookbooksDir) + if ignorer.is_a?(ChefRepositoryFileSystemCookbookDir) # Grab the path from entry to child path_to_child = name child = self - while child.parent != ignorer + while child != ignorer path_to_child = PathUtils.join(child.name, path_to_child) child = child.parent end diff --git a/lib/chef/cookbook/chefignore.rb b/lib/chef/cookbook/chefignore.rb index 53f62818ab..763f5325cc 100644 --- a/lib/chef/cookbook/chefignore.rb +++ b/lib/chef/cookbook/chefignore.rb @@ -68,8 +68,6 @@ class Chef file = dir.join("chefignore") return file.expand_path.to_s if file.exist? - - Chef::Log.debug("No chefignore file found at #{file}") end nil diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb index 6c1f710f6d..073323da05 100644 --- a/lib/chef/cookbook/syntax_check.rb +++ b/lib/chef/cookbook/syntax_check.rb @@ -84,11 +84,13 @@ class Chef # If no +cookbook_path+ is given, +Chef::Config.cookbook_path+ is used. def self.for_cookbook(cookbook_name, cookbook_path = nil) cookbook_path ||= Chef::Config.cookbook_path - unless cookbook_path - raise ArgumentError, "Cannot find cookbook #{cookbook_name} unless Chef::Config.cookbook_path is set or an explicit cookbook path is given" + + Array(cookbook_path).each do |entry| + path = File.expand_path(File.join(entry, cookbook_name.to_s)) + return new(path) if Dir.exist?(path) end - new(File.join(cookbook_path, cookbook_name.to_s)) + raise ArgumentError, "Cannot find cookbook #{cookbook_name} unless Chef::Config.cookbook_path is set or an explicit cookbook path is given" end # Create a new SyntaxCheck object diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb index b27d751d64..2bafed410d 100644 --- a/lib/chef/cookbook_loader.rb +++ b/lib/chef/cookbook_loader.rb @@ -49,8 +49,8 @@ class Chef # @param repo_paths [Array<String>] the array of repo paths containing cookbook dirs def initialize(*repo_paths) - @repo_paths = repo_paths.flatten.map { |p| File.expand_path(p) } - raise ArgumentError, "You must specify at least one cookbook repo path" if repo_paths.empty? + @repo_paths = repo_paths.flatten.compact.map { |p| File.expand_path(p) } + raise ArgumentError, "You must specify at least one cookbook repo path" if @repo_paths.empty? end # The primary function of this class is to build this Mash mapping cookbook names as a string to @@ -171,7 +171,7 @@ class Chef begin mash = Mash.new all_directories_in_repo_paths.each do |cookbook_path| - loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore(File.dirname(cookbook_path))) + loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore(cookbook_path)) cookbook_name = loader.cookbook_name if mash.key?(cookbook_name) raise Chef::Exceptions::CookbookMergingError, "Cookbook merging is no longer supported, the cookbook named #{cookbook_name} can only appear once in the cookbook_path" |