-
Notifications
You must be signed in to change notification settings - Fork 22
permit symlinks in config directory #18
permit symlinks in config directory #18
Conversation
You can specify multi configuration directories in |
@portertech: this ok? |
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this increase by 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"loading config file" & "config file applied changes"
…support doesn't add possibility of causing an infinite loop
@@ -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| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the uniq() for? Shouldn't have duplicate file paths, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The glob seems to match files multiple times:
[7] pry(main)> Dir.glob(File.join("**/*.json")) { |i| puts i }
nested/file.json
merger.json
=> nil
[8] pry(main)> Dir.glob(File.join("**{,/*/**}/*.json")) { |i| puts i }
nested/file.json
merger.json
nested/file.json
alternative/symlinked.json
=> nil
Took the glob from here: http://stackoverflow.com/questions/357754/can-i-traverse-symlinked-directories-in-ruby-with-a-glob
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we need a uniq()
anyways, as this pattern along w/ alternatives, will pick up a symlink to a dir that it has already listed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, it is still a uniq file path :P
permit symlinks in config directory
We have a situation where our
conf.d
directory is maintained by Puppet, but our application layer is deployed by Ansible. We deploy apps intoopt/<app>-<instance>
and the sensu check configs into a subdir calledchecks
. We then create a symlink/etc/sensu/conf.d/app/<app>-<id>
to thechecks
dir so that if an app gets removed we're just left with a dead symlink, rather than Sensu loading checks for apps that have been removed. Later, a puppet job comes along and removes dead symlinks.Convoluted, I know. Regardless, I think permitting symlinks in
conf.d
should be acceptable :)