summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-02-08 16:04:27 -0800
committerdanielsdeleo <dan@chef.io>2016-02-16 15:26:43 -0800
commit9b64078d1012443a146080a5197303bb9cbb2baa (patch)
treee3dfe0a1acd29bb8b3bee8fc5730def79d73a3a3
parentc5416667d86a47f00b4664e297fb589f2c7bf54b (diff)
downloadchef-9b64078d1012443a146080a5197303bb9cbb2baa.tar.gz
Fix knife integration tests
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/repository/data_bag.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/data_bag_item.rb17
-rw-r--r--lib/chef/chef_fs/file_system/repository/directory.rb26
4 files changed, 37 insertions, 12 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 307866c350..9111b14747 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
@@ -159,6 +159,10 @@ class Chef
parent.root
end
+ def compare_to(other)
+ nil
+ end
+
protected
def make_child_entry(child_name)
diff --git a/lib/chef/chef_fs/file_system/repository/data_bag.rb b/lib/chef/chef_fs/file_system/repository/data_bag.rb
index 0c1b155bd1..fb3ad9da77 100644
--- a/lib/chef/chef_fs/file_system/repository/data_bag.rb
+++ b/lib/chef/chef_fs/file_system/repository/data_bag.rb
@@ -37,5 +37,3 @@ class Chef
end
end
end
-
-
diff --git a/lib/chef/chef_fs/file_system/repository/data_bag_item.rb b/lib/chef/chef_fs/file_system/repository/data_bag_item.rb
index 8b25338134..ef4c7e9c6e 100644
--- a/lib/chef/chef_fs/file_system/repository/data_bag_item.rb
+++ b/lib/chef/chef_fs/file_system/repository/data_bag_item.rb
@@ -28,8 +28,6 @@ class Chef
attr_reader :name
attr_reader :parent
attr_reader :path
- attr_reader :ruby_only
- attr_reader :recursive
attr_reader :file_path
def initialize(name, parent)
@@ -40,8 +38,17 @@ class Chef
@file_path = "#{parent.file_path}/#{name}"
end
+ # Public API callied by chef_fs/file_system
+ def dir?
+ false
+ end
+
def name_valid?
- !name.start_with?(".")
+ !name.start_with?(".") && name.end_with?(".json")
+ end
+
+ def fs_entry_valid?
+ name_valid? && File.file?(file_path)
end
def create(file_contents)
@@ -96,10 +103,12 @@ class Chef
parent.root
end
+ def compare_to(other)
+ nil
+ end
end
end
end
end
end
-
diff --git a/lib/chef/chef_fs/file_system/repository/directory.rb b/lib/chef/chef_fs/file_system/repository/directory.rb
index 1a8ea29a9a..ac1ac0a852 100644
--- a/lib/chef/chef_fs/file_system/repository/directory.rb
+++ b/lib/chef/chef_fs/file_system/repository/directory.rb
@@ -39,11 +39,24 @@ class Chef
!name.start_with?(".")
end
+ # Whether or not the file system entry this object represents is
+ # valid. Mainly used to trim dotfiles/dotdirs and non directories
+ # from the list of children when enumerating items on the filesystem
+ def fs_entry_valid?
+ name_valid? && File.directory?(file_path)
+ end
+
# ChefFS API:
- # Public api called by multiplexed_dir
+ # Public API called by multiplexed_dir
def can_have_child?(name, is_dir)
- is_dir && make_child_entry(name).name_valid?
+ possible_child = make_child_entry(name)
+ possible_child.dir? == is_dir && possible_child.name_valid?
+ end
+
+ # Public API callied by chef_fs/file_system
+ def dir?
+ true
end
def path_for_printing
@@ -52,7 +65,8 @@ class Chef
def children
dir_ls.sort.
- map { |child_name| make_child_entry(child_name) }
+ map { |child_name| make_child_entry(child_name) }.
+ select { |maybe_child| maybe_child.fs_entry_valid? }
rescue Errno::ENOENT => e
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
end
@@ -66,6 +80,7 @@ class Chef
children.empty?
end
+ # Public API callied by chef_fs/file_system
def child(name)
possible_child = make_child_entry(name)
if possible_child.name_valid?
@@ -83,12 +98,12 @@ class Chef
def create(file_contents = nil)
if exists?
- raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
+ raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, self)
end
begin
Dir.mkdir(file_path)
rescue Errno::EEXIST
- raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
+ raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, self)
end
end
@@ -122,4 +137,3 @@ class Chef
end
end
end
-