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 <m...@puppetlabs.com> Signed-off-by: Jacob Helwig <ja...@puppetlabs.com> --- Local-branch: tickets/master/7039-multiple-facts-same-file lib/facter/application.rb | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) 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 -- 1.7.4.3 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.