diff options
11 files changed, 41 insertions, 12 deletions
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb index fb5ee96c87..69dce54f00 100644 --- a/lib/chef/chef_fs/file_system.rb +++ b/lib/chef/chef_fs/file_system.rb @@ -52,13 +52,13 @@ class Chef def list_from(entry, &block) # Include self in results if it matches - if pattern.match?(entry.path) + if pattern.match?(entry.display_path) yield(entry) end - if pattern.could_match_children?(entry.path) + if pattern.could_match_children?(entry.display_path) # If it's possible that our children could match, descend in and add matches. - exact_child_name = pattern.exact_child_name_under(entry.path) + exact_child_name = pattern.exact_child_name_under(entry.display_path) # If we've got an exact name, don't bother listing children; just grab the # child with the given name. @@ -222,14 +222,14 @@ class Chef result = [] a_children_names = Set.new a.children.each do |a_child| - a_children_names << a_child.name - result << [ a_child, b.child(a_child.name) ] + a_children_names << a_child.bare_name + result << [ a_child, b.child(a_child.bare_name) ] end # Check b for children that aren't in a b.children.each do |b_child| - if !a_children_names.include?(b_child.name) - result << [ a.child(b_child.name), b_child ] + if !a_children_names.include?(b_child.bare_name) + result << [ a.child(b_child.bare_name), b_child ] end end result diff --git a/lib/chef/chef_fs/file_system/base_fs_object.rb b/lib/chef/chef_fs/file_system/base_fs_object.rb index 6abbcf343f..9767b5b1ba 100644 --- a/lib/chef/chef_fs/file_system/base_fs_object.rb +++ b/lib/chef/chef_fs/file_system/base_fs_object.rb @@ -40,6 +40,10 @@ class Chef attr_reader :parent attr_reader :path + alias_method :display_path, :path + alias_method :display_name, :name + alias_method :bare_name, :name + # Override this if you have a special comparison algorithm that can tell # you whether this entry is the same as another--either a quicker or a # more reliable one. Callers will use this to decide whether to upload, 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 277cabe3a1..f4655412fa 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 @@ -36,7 +36,6 @@ class Chef else "/acls/#{parent.name}/#{name}" end - # Chef::Log.warn "Display Path is #{pth}" File.extname(pth).empty? ? pth + ".json" : pth 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 index 3d70a61fb5..c0093058b7 100644 --- 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 @@ -17,4 +17,3 @@ class Chef end end 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 b56f6636d4..b8ec5f8524 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 @@ -54,6 +54,10 @@ class Chef end alias_method :path_for_printing, :display_path + def display_name + File.basename(display_path) + end + def org parent.org end diff --git a/lib/chef/chef_fs/file_system/repository/acl.rb b/lib/chef/chef_fs/file_system/repository/acl.rb index e2ba2e8771..023ae11379 100644 --- a/lib/chef/chef_fs/file_system/repository/acl.rb +++ b/lib/chef/chef_fs/file_system/repository/acl.rb @@ -31,6 +31,13 @@ class Chef super end + def bare_name + if name == "organization" && parent.kind_of?(AclDir) + "organization.json" + else + name + end + end end end end diff --git a/lib/chef/chef_fs/file_system/repository/base_file.rb b/lib/chef/chef_fs/file_system/repository/base_file.rb index 344f9e6085..a768bcf971 100644 --- a/lib/chef/chef_fs/file_system/repository/base_file.rb +++ b/lib/chef/chef_fs/file_system/repository/base_file.rb @@ -29,6 +29,9 @@ class Chef attr_reader :file_path attr_reader :data_handler + alias_method :display_path, :path + alias_method :display_name, :name + def initialize(name, parent) @parent = parent @@ -53,6 +56,11 @@ class Chef false end + # Used to compare names on disk to the API, for diffing. + def bare_name + File.basename(name, ".*") + end + def is_json_file? File.extname(file_path) == ".json" end 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 703c0fc635..9d1538e46e 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 @@ -37,6 +37,10 @@ class Chef attr_reader :recursive attr_reader :file_path + alias_method :display_path, :path + alias_method :display_name, :name + alias_method :bare_name, :name + def initialize(name, parent, file_path = nil, ruby_only = false, recursive = false) @parent = parent @name = name diff --git a/lib/chef/chef_fs/file_system/repository/directory.rb b/lib/chef/chef_fs/file_system/repository/directory.rb index 20f6f82108..dae467993a 100644 --- a/lib/chef/chef_fs/file_system/repository/directory.rb +++ b/lib/chef/chef_fs/file_system/repository/directory.rb @@ -28,6 +28,10 @@ class Chef attr_reader :path attr_reader :file_path + alias_method :display_path, :path + alias_method :display_name, :name + alias_method :bare_name, :name + def initialize(name, parent, file_path = nil) @parent = parent @name = name diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb index 3d1583b270..a109504788 100644 --- a/lib/chef/knife/list.rb +++ b/lib/chef/knife/list.rb @@ -95,7 +95,7 @@ class Chef printed_something = true end output "#{format_path(result)}:" - print_results(children.map { |result| maybe_add_slash(result.name, result.dir?) }.sort, "") + print_results(children.map { |result| maybe_add_slash(result.display_name, result.dir?) }.sort, "") end exit self.exit_code if self.exit_code diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb index de0872d39c..40eb85cc65 100644 --- a/spec/integration/knife/deps_spec.rb +++ b/spec/integration/knife/deps_spec.rb @@ -630,8 +630,8 @@ EOM it "knife deps /data_bags/bag/item reports an error" do knife("deps --remote /data_bags/bag/item").should_fail( :exit_code => 2, - :stdout => "/data_bags/bag/item\n", - :stderr => "ERROR: /data_bags/bag/item: No such file or directory\n" + :stdout => "/data_bags/bag/item.json\n", + :stderr => "ERROR: /data_bags/bag/item.json: No such file or directory\n" ) end end |