summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/chef_fs/config.rb2
-rw-r--r--lib/chef/chef_fs/file_system.rb10
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/acl_entry.rb10
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb6
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/data_bag_entry.rb20
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/org_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb5
-rw-r--r--lib/chef/chef_fs/file_system/multiplexed_dir.rb4
11 files changed, 66 insertions, 7 deletions
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb
index 6e3cc50ac1..63a1363724 100644
--- a/lib/chef/chef_fs/config.rb
+++ b/lib/chef/chef_fs/config.rb
@@ -242,7 +242,7 @@ class Chef
# Print the given server path, relative to the current directory
def format_path(entry)
- server_path = entry.path
+ server_path = entry.respond_to?(:display_path) ? entry.display_path : entry.path
if base_path && server_path[0, base_path.length] == base_path
if server_path == base_path
return "."
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb
index 8b622486fa..fb5ee96c87 100644
--- a/lib/chef/chef_fs/file_system.rb
+++ b/lib/chef/chef_fs/file_system.rb
@@ -186,16 +186,16 @@ class Chef
# Make sure everything on the server is also on the filesystem, and diff
found_paths = Set.new
Chef::ChefFS::FileSystem.list(a_root, pattern).each do |a|
- found_paths << a.path
- b = Chef::ChefFS::FileSystem.resolve_path(b_root, a.path)
+ found_paths << a.display_path
+ b = Chef::ChefFS::FileSystem.resolve_path(b_root, a.display_path)
yield [ a, b ]
end
# Check the outer regex pattern to see if it matches anything on the
# filesystem that isn't on the server
Chef::ChefFS::FileSystem.list(b_root, pattern).each do |b|
- if !found_paths.include?(b.path)
- a = Chef::ChefFS::FileSystem.resolve_path(a_root, b.path)
+ if !found_paths.include?(b.display_path)
+ a = Chef::ChefFS::FileSystem.resolve_path(a_root, b.display_path)
yield [ a, b ]
end
end
@@ -392,6 +392,8 @@ class Chef
end
end
end
+ rescue RubyFileError => e
+ ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
rescue DefaultEnvironmentCannotBeModifiedError => e
ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
rescue OperationFailedError => e
diff --git a/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb b/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb
index 68df3704bf..277cabe3a1 100644
--- a/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb
@@ -30,6 +30,16 @@ class Chef
"#{super}/_acl"
end
+ def display_path
+ pth = if parent.name == "acls"
+ "/acls/#{name}"
+ else
+ "/acls/#{parent.name}/#{name}"
+ end
+ # Chef::Log.warn "Display Path is #{pth}"
+ File.extname(pth).empty? ? pth + ".json" : pth
+ end
+
def delete(recurse)
raise Chef::ChefFS::FileSystem::OperationNotAllowedError.new(:delete, self, nil, "ACLs cannot be deleted")
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb b/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb
index 5ad0063807..ee0ecd3b40 100644
--- a/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb
@@ -17,6 +17,7 @@
#
require "chef/chef_fs/file_system/chef_server/rest_list_dir"
+require "chef/chef_fs/file_system/chef_server/data_bag_entry"
require "chef/chef_fs/file_system/exceptions"
require "chef/chef_fs/data_handler/data_bag_item_data_handler"
@@ -63,6 +64,11 @@ class Chef
end
end
end
+
+ def make_child_entry(name, exists = nil)
+ @children.find { |child| child.name == name } if @children
+ DataBagEntry.new(name, self, exists)
+ end
end
end
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/data_bag_entry.rb b/lib/chef/chef_fs/file_system/chef_server/data_bag_entry.rb
new file mode 100644
index 0000000000..3d70a61fb5
--- /dev/null
+++ b/lib/chef/chef_fs/file_system/chef_server/data_bag_entry.rb
@@ -0,0 +1,20 @@
+require "chef/chef_fs/file_system/chef_server/rest_list_entry"
+require "chef/chef_fs/data_handler/data_bag_item_data_handler"
+
+class Chef
+ module ChefFS
+ module FileSystem
+ module ChefServer
+ # /policies/NAME-REVISION.json
+ # Represents the actual data at /organizations/ORG/policies/NAME/revisions/REVISION
+ class DataBagEntry < RestListEntry
+ def display_path
+ pth = "/data_bags/#{parent.name}/#{name}"
+ File.extname(pth).empty? ? pth + ".json" : pth
+ end
+ end
+ end
+ end
+ end
+end
+
diff --git a/lib/chef/chef_fs/file_system/chef_server/org_entry.rb b/lib/chef/chef_fs/file_system/chef_server/org_entry.rb
index 87be36b932..7253de3449 100644
--- a/lib/chef/chef_fs/file_system/chef_server/org_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/org_entry.rb
@@ -17,6 +17,10 @@ class Chef
parent.api_path
end
+ def display_path
+ "/org.json"
+ end
+
def exists?
parent.exists?
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
index 37b7af8b5e..adaffb99a7 100644
--- a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
@@ -27,6 +27,10 @@ class Chef
File.join(parent.api_path, "association_requests")
end
+ def display_path
+ "/invitations.json"
+ end
+
def exists?
parent.exists?
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb
index 2e45b74450..7e9c7141c4 100644
--- a/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb
@@ -27,6 +27,10 @@ class Chef
File.join(parent.api_path, "users")
end
+ def display_path
+ "/members.json"
+ end
+
def exists?
parent.exists?
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb b/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
index d083383a0e..325b18e429 100644
--- a/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
@@ -14,6 +14,10 @@ class Chef
"#{parent.api_path}/#{policy_name}/revisions/#{revision_id}"
end
+ def display_path
+ "/policies/#{policy_name}-#{revision_id}.json"
+ end
+
def write(file_contents)
raise OperationNotAllowedError.new(:write, self, nil, "cannot be updated: policy revisions are immutable once uploaded. If you want to change the policy, create a new revision with your changes")
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
index 9b16bd80de..2cdf9edab3 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
@@ -47,6 +47,11 @@ class Chef
"#{parent.api_path}/#{api_child_name}"
end
+ def display_path
+ pth = api_path.start_with?("/") ? api_path : "/#{api_path}"
+ File.extname(pth).empty? ? pth + ".json" : pth
+ end
+
def org
parent.org
end
diff --git a/lib/chef/chef_fs/file_system/multiplexed_dir.rb b/lib/chef/chef_fs/file_system/multiplexed_dir.rb
index e143dde9e8..d3951edd51 100644
--- a/lib/chef/chef_fs/file_system/multiplexed_dir.rb
+++ b/lib/chef/chef_fs/file_system/multiplexed_dir.rb
@@ -24,7 +24,7 @@ class Chef
multiplexed_dirs.each do |dir|
dir.children.each do |child|
if seen[child.name]
- Chef::Log.warn("Child with name '#{child.name}' found in multiple directories: #{seen[child.name].path_for_printing} and #{child.path_for_printing}")
+ Chef::Log.warn("Child with name '#{child.name}' found in multiple directories: #{seen[child.name].path_for_printing} and #{child.path_for_printing}") unless seen[child.name].path_for_printing == child.path_for_printing
else
result << child
seen[child.name] = child
@@ -41,7 +41,7 @@ class Chef
child_entry = dir.child(name)
if child_entry.exists?
if result
- Chef::Log.warn("Child with name '#{child_entry.name}' found in multiple directories: #{result.parent.path_for_printing} and #{child_entry.parent.path_for_printing}")
+ Chef::Log.debug("Child with name '#{child_entry.name}' found in multiple directories: #{result.parent.path_for_printing} and #{child_entry.parent.path_for_printing}") unless seen[child.name].path_for_printing == child.path_for_printing
else
result = child_entry
end