Skip to content

Commit

Permalink
Use escape_glob_dir for client.d/conf.d
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jaym committed Feb 17, 2016
1 parent 5b3ef70 commit b5e6119
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion chef-config/lib/chef-config/workstation_config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def conf_d_files
@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)
Expand Down
2 changes: 1 addition & 1 deletion lib/chef/application/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def load_config_d_file(f)

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
[]
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/application/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@

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
Expand Down

0 comments on commit b5e6119

Please sign in to comment.