summaryrefslogtreecommitdiff
path: root/lib/chef/data_bag.rb
diff options
context:
space:
mode:
authoryoungjl1 <luke.young@gmail.com>2015-12-16 23:05:24 -0500
committerJay Mundrawala <jdmundrawala@gmail.com>2016-02-16 19:07:55 -0800
commit8417850f5b3bba689694a4114502034600a44602 (patch)
treeb45461c929a04614dce91c3d18c7bc0c9d53a449 /lib/chef/data_bag.rb
parenta028bda72981a9b58427054d51d69a58b45badc2 (diff)
downloadchef-8417850f5b3bba689694a4114502034600a44602.tar.gz
Fix databag globbing issues for chef-solo on windows
Backslashes should not be passed to Dir, as it does not work when globbing in many cases. Created new function that can be used with dir on windows. `escape_glob_dir` should be used when the result is going to be passed into Dir. Fixes #4194 Replaces #4195
Diffstat (limited to 'lib/chef/data_bag.rb')
-rw-r--r--lib/chef/data_bag.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index d17dd8dc90..2852055203 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -98,8 +98,8 @@ class Chef
unless File.directory?(path)
raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' is invalid"
end
-
- names += Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(path), "*")).map { |f| File.basename(f) }.sort
+
+ names += Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path), "*")).map{|f|File.basename(f)}.sort
end
names.inject({}) { |h, n| h[n] = n; h }
else
@@ -125,7 +125,7 @@ class Chef
raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{path}' is invalid"
end
- Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(path, name.to_s), "*.json")).inject({}) do |bag, f|
+ Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path, name.to_s), "*.json")).inject({}) do |bag, f|
item = Chef::JSONCompat.parse(IO.read(f))
# Check if we have multiple items with similar names (ids) and raise if their content differs