From 5c53617aba31abaa7becd9725155b570fac2a90d Mon Sep 17 00:00:00 2001 From: AJ Christensen Date: Wed, 30 Jul 2008 11:33:18 +1200 Subject: Added a search method to the YAML indirector. This performs a glob on the YAML directory, and instances everything it finds --- lib/puppet/indirector/yaml.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index 3573ba560..3f05ce618 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -34,11 +34,20 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus end end + # Get the yaml directory + def base + (Puppet[:name] == "puppetmasterd") ? Puppet[:yamldir] : Puppet[:clientyamldir] + end + # Return the path to a given node's file. def path(name) - base = (Puppet[:name] == "puppetmasterd") ? Puppet[:yamldir] : Puppet[:clientyamldir] File.join(base, self.class.indirection_name.to_s, name.to_s + ".yaml") end + + # Do a glob on the yaml directory, loading each file found + def search(request) + Dir.glob(File.join(base, self.class.indirection_name.to_s, request.key)).collect { |f| YAML.load_file(f) } + end private -- cgit