summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-05-31 13:14:18 -0700
committerNick Lewis <nick@puppetlabs.com>2011-05-31 15:35:40 -0700
commit2255abee7bdb9b6478ca228546e3d275dbac0ec3 (patch)
treed09703a3753b6541f1b0267d817c4eecdf7a75a1 /lib
parent59173268a5c6525a4a5df55b362775d07bc6b52d (diff)
downloadfacter-2255abee7bdb9b6478ca228546e3d275dbac0ec3.tar.gz
facter-2255abee7bdb9b6478ca228546e3d275dbac0ec3.tar.xz
facter-2255abee7bdb9b6478ca228546e3d275dbac0ec3.zip
(#7670) Never fail to find a fact that is present
With the previous behavior, any fact which depended on another fact in a file not matching its name would fail to properly load the required fact, resulting in missing, incorrect, or inconsistent values. For instance, the operatingsystem fact depends on the lsbdistid fact found in lsb.rb. The first time the operatingsystem fact is requested, it requires lsb.rb, and so the required fact is loaded first. But if Facter is subsequently cleared and the operatingsystem fact requested again, the require will not occur, and the fact will not be automatically loaded because it doesn't match its filename. Now if a fact is requested and can't be found, we will attempt to load all the facts to find it. Such an approach appears heavy-handed, but in the case where we want a particular fact, this is the only way to make sure we've found it. In the case where we eventually want other facts, we are conveniently eagerly loading them. Paired-With: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/facter/util/collection.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/facter/util/collection.rb b/lib/facter/util/collection.rb
index 3f8e0f8..b3d3a45 100644
--- a/lib/facter/util/collection.rb
+++ b/lib/facter/util/collection.rb
@@ -66,9 +66,13 @@ class Facter::Util::Collection
def fact(name)
name = canonize(name)
+ # Try to load the fact if necessary
loader.load(name) unless @facts[name]
- return @facts[name]
+ # Try HARDER
+ loader.load_all unless @facts[name]
+
+ @facts[name]
end
# Flush all cached values.