[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, experimental, updated. debian/1.5.8-2-160-gb26a2a8

Jacob Helwig jacob at puppetlabs.com
Tue May 10 08:40:09 UTC 2011


The following commit has been merged in the experimental branch:
commit a75f0f9bc7ea1e03dc3a19fba8fae61165ab2b05
Author: Jacob Helwig <jacob at puppetlabs.com>
Date:   Tue Apr 12 11:15:06 2011 -0700

    (#7039) Pre-load all facts when requesting a single fact
    
    Since multiple facts can be defined in a single file and we have no
    way of knowing which "additional" facts are defined in which files, we
    pre-load all facts when we're looking for specific one.
    
    Paired-with: Max Martin <max at puppetlabs.com>

diff --git a/lib/facter/application.rb b/lib/facter/application.rb
index 6b351b1..bd68149 100644
--- a/lib/facter/application.rb
+++ b/lib/facter/application.rb
@@ -9,19 +9,21 @@ module Facter
       # Accept fact names to return from the command line
       names = argv
 
-      # Create the facts hash that is printed to standard out
-      if names.empty?
-        facts = Facter.to_hash
-      else
+      # Create the facts hash that is printed to standard out.
+      # Pre-load all of the facts, since we can have multiple facts
+      # per file, and since we can't know ahead of time which file a
+      # fact will be in, we'll need to load every file.
+      facts = Facter.to_hash
+      unless names.empty?
         facts = {}
-        names.each { |name|
+        names.each do |name|
           begin
             facts[name] = Facter.value(name)
           rescue => error
             $stderr.puts "Could not retrieve #{name}: #{error}"
             exit 10
           end
-        }
+        end
       end
 
       # Print the facts as YAML and exit

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list