summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2016-02-16 21:16:45 -0800
committerJay Mundrawala <jdmundrawala@gmail.com>2016-02-24 21:24:15 -0800
commitb5b94dc98bca9e0158b6ddab29e14ca4edf5ac02 (patch)
treeb63f367a9095c110e1ac0099963e1a421f2cc984
parent05f5c6727a9dc9f32ef78bafb059f2dd26194724 (diff)
downloadchef-b5b94dc98bca9e0158b6ddab29e14ca4edf5ac02.tar.gz
Use escape_glob_dir for client.d/conf.d
Passing the value of `escape_glob` to Dir.glob does not always work correctly on Windows. Always use forward slashes when globbing, even on Windows. We now do this via `escape_glob_dir`, which calls Pathname.cleanpath, which does the foward slash thing.
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb2
-rw-r--r--lib/chef/application/client.rb2
-rw-r--r--spec/unit/application/client_spec.rb8
3 files changed, 6 insertions, 6 deletions
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index 63731b729d..efc7049ec1 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -136,7 +136,7 @@ module ChefConfig
@conf_d_files ||=
begin
entries = Array.new
- entries << Dir.glob(File.join(PathHelper.escape_glob(
+ entries << Dir.glob(File.join(PathHelper.escape_glob_dir(
Config[:conf_d_dir]), "*.rb")) if Config[:conf_d_dir]
entries.flatten.select do |entry|
File.file?(entry)
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 7de6bb05c2..9d67754325 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -526,7 +526,7 @@ class Chef::Application::Client < Chef::Application
def list_config_d_files
if Chef::Config[:client_d_dir]
- Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(
+ Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(
Chef::Config[:client_d_dir]), "*.rb"))
else
[]
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 0bf23a8b54..834c7777f0 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -279,10 +279,10 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
it "loads the configuration in order" do
- expect(::File).to receive(:read).with(Chef::Config.platform_specific_path("#{client_d_dir}/00-foo.rb")).and_return("")
- expect(::File).to receive(:read).with(Chef::Config.platform_specific_path("#{client_d_dir}/01-bar.rb")).and_return("")
- expect(app).to receive(:load_config_d_file).with("#{client_d_dir}/00-foo.rb").and_call_original.ordered
- expect(app).to receive(:load_config_d_file).with("#{client_d_dir}/01-bar.rb").and_call_original.ordered
+ expect(::File).to receive(:read).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_return("")
+ expect(::File).to receive(:read).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_return("")
+ expect(app).to receive(:load_config_d_file).with(Pathname.new("#{client_d_dir}/00-foo.rb").cleanpath.to_s).and_call_original.ordered
+ expect(app).to receive(:load_config_d_file).with(Pathname.new("#{client_d_dir}/01-bar.rb").cleanpath.to_s).and_call_original.ordered
app.reconfigure
end
end