Please review pull request #63: Adds doc about :undefined opened by (wcooley)

Description:

This commit adds mention of the :undefined return value of lookupvar, as I reported in bug #13869.

  • Opened: Wed Apr 11 04:55:40 UTC 2012
  • Based on: puppetlabs:master (3201c018ac188b070dea0e18cccb51b07871b379)
  • Requested merge: wcooley:fix-13869 (e80a83e87face3965743a029325075be9a71fd5c)

Diff follows:

diff --git a/source/guides/custom_functions.markdown b/source/guides/custom_functions.markdown
index e61ae5c..758228f 100644
--- a/source/guides/custom_functions.markdown
+++ b/source/guides/custom_functions.markdown
@@ -40,7 +40,8 @@ your functions:
     same as the name of function; otherwise it won't get automatically
     loaded.
 -   To use a *fact* about a client, use `lookupvar('{fact name}')`
-    instead of `Facter['{fact name}'].value`. See examples below.
+    instead of `Facter['{fact name}'].value`.  If the *fact* does not
+    exist, `lookupvar` returns `:undefined`. See examples below.
 
 ### Where to put your functions
 
@@ -147,6 +148,14 @@ functions.
       end
     end
 
+### Example 3
+
+    module Puppet::Parser::Functions
+      newfunction(:has_fact, :type => :rvalue) do |arg|
+        lookupvar(arg[0]) != :undefined
+      end
+    end
+
 Basically, to get a fact's or variable's value, you just call
 `lookupvar('{fact name}')`.
 

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to