From bb41db0bf4221e394411d2a82b6de264b557fb95 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 16 May 2008 10:38:15 -0500 Subject: Switching to a search path registration system. Facter no longer knows anything about Puppet, so there's no inter-dependency issue. --- lib/facter.rb | 12 ++++++++++++ lib/facter/util/loader.rb | 15 +++------------ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/facter.rb b/lib/facter.rb index aae3326..525dbcd 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -179,4 +179,16 @@ module Facter def self.loadfacts collection.load_all end + + @search_path = [] + + # Register a directory to search through. + def self.search(*dirs) + @search_path += dirs + end + + # Return our registered search directories. + def self.search_path + @search_path.dup + end end diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb index 44a0338..c6013cc 100644 --- a/lib/facter/util/loader.rb +++ b/lib/facter/util/loader.rb @@ -51,18 +51,9 @@ class Facter::Util::Loader result += ENV["FACTERLIB"].split(":") end - # LAK:NOTE We have to be this careful because facter gets loaded - # *very* early in Puppet's lifecycle, and this essentially - # builds interdependencies between the applications, which is - # tricky. - if defined?(Puppet) and Puppet.respond_to?(:settings) - if f = Puppet.settings.value(:factdest) - result << f - end - if l = Puppet.settings.value(:libdir) - result << File.join(l, "facter") - end - end + # This allows others to register additional paths we should search. + result += Facter.search_path + result end -- cgit