diff --git a/lib/sensu/settings/loader.rb b/lib/sensu/settings/loader.rb index 4007891..de20821 100644 --- a/lib/sensu/settings/loader.rb +++ b/lib/sensu/settings/loader.rb @@ -124,7 +124,7 @@ def load_file(file) def load_directory(directory) warning("loading config files from directory", :directory => directory) path = directory.gsub(/\\(?=\S)/, "/") - Dir.glob(File.join(path, "**/*.json")).each do |file| + Dir.glob(File.join(path, "**{,/*/**}/*.json")).uniq.each do |file| load_file(file) end end diff --git a/spec/assets/alternative/conf.d/loop b/spec/assets/alternative/conf.d/loop new file mode 120000 index 0000000..e5ef02d --- /dev/null +++ b/spec/assets/alternative/conf.d/loop @@ -0,0 +1 @@ +../conf.d \ No newline at end of file diff --git a/spec/assets/alternative/conf.d/symlinked.json b/spec/assets/alternative/conf.d/symlinked.json new file mode 100644 index 0000000..0fb3f9e --- /dev/null +++ b/spec/assets/alternative/conf.d/symlinked.json @@ -0,0 +1,11 @@ +{ + "checks": { + "symlinked": { + "command": "echo -n symlinked", + "subscribers": [ + "baz" + ], + "interval": 60 + } + } +} diff --git a/spec/assets/conf.d/alternative b/spec/assets/conf.d/alternative new file mode 120000 index 0000000..506c23d --- /dev/null +++ b/spec/assets/conf.d/alternative @@ -0,0 +1 @@ +../alternative/conf.d/ \ No newline at end of file diff --git a/spec/loader_spec.rb b/spec/loader_spec.rb index 84bf641..5009779 100644 --- a/spec/loader_spec.rb +++ b/spec/loader_spec.rb @@ -139,7 +139,7 @@ it "can load settings from files in a directory" do @loader.load_directory(@config_dir) warnings = @loader.warnings - expect(warnings.size).to eq(4) + expect(warnings.size).to eq(6) messages = warnings.map do |warning| warning[:message] end @@ -159,7 +159,7 @@ it "can set environment variables for child processes" do @loader.load_file(@config_file) @loader.load_directory(@config_dir) - expect(@loader.loaded_files.size).to eq(3) + expect(@loader.loaded_files.size).to eq(4) @loader.set_env! expect(ENV["SENSU_LOADED_TEMPFILE"]).to match(/sensu_rspec_loaded_files/) loaded_files = IO.read(ENV["SENSU_LOADED_TEMPFILE"])