[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Nick Lewis nick at puppetlabs.com
Tue May 10 08:12:44 UTC 2011


The following commit has been merged in the experimental branch:
commit d7201ed38929f867d31bc9b916e90679606dc9f8
Author: Markus Roberts <Markus at reality.com>
Date:   Sun Oct 24 15:37:31 2010 -0700

    Refactor for 5027 -- get rid of lookup_qualified_var
    
    Scope#lookup_qualified_var was a "magic bag" that took a qualified variable
    name apart and called back in to lookupvar with a new scope.  This commit is
    a semantically neutral refactor that replaces it with a function to find the
    desired scope as a pure function (with error detection).

diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index f7a0134..95b765b 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -214,30 +214,25 @@ class Puppet::Parser::Scope
     (v == :undefined) ? x : (v == :undef) ? x : v
   end
 
-  def lookup_qualified_var(name)
-    parts = name.split(/::/)
-    shortname = parts.pop
-    klassname = parts.join("::")
-    klass = find_hostclass(klassname)
-    unless klass
-      warning "Could not look up qualified variable '#{name}'; class #{klassname} could not be found"
-      return :undefined
-    end
-    unless kscope = class_scope(klass)
-      warning "Could not look up qualified variable '#{name}'; class #{klassname} has not been evaluated"
-      return :undefined
-    end
-    kscope.lookupvar(shortname)
+  def qualified_scope(classname)
+    raise "class #{classname} could not be found"     unless klass = find_hostclass(classname)
+    raise "class #{classname} has not been evaluated" unless kscope = class_scope(klass)
+    kscope
   end
 
-  private :lookup_qualified_var
+  private :qualified_scope
 
   # Look up a variable.  The simplest value search we do.  
   def lookupvar(name)
     table = ephemeral?(name) ? @ephemeral.last : @symtable
     # If the variable is qualified, then find the specified scope and look the variable up there instead.
-    if name =~ /::/
-      lookup_qualified_var(name)
+    if name =~ /^(.*)::(.+)$/
+      begin 
+        qualified_scope($1).lookupvar($2)
+      rescue RuntimeError => e
+        warning "Could not look up qualified variable '#{name}'; #{e.message}"
+        :undefined
+      end
     elsif ephemeral_include?(name) or table.include?(name)
       # We can't use "if table[name]" here because the value might be false
       table[name]

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list