summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/ast/objectdef.rb46
-rw-r--r--lib/puppet/parser/scope.rb17
2 files changed, 18 insertions, 45 deletions
diff --git a/lib/puppet/parser/ast/objectdef.rb b/lib/puppet/parser/ast/objectdef.rb
index 0a9ba23cd..9acf56b49 100644
--- a/lib/puppet/parser/ast/objectdef.rb
+++ b/lib/puppet/parser/ast/objectdef.rb
@@ -65,8 +65,7 @@ class Puppet::Parser::AST
end
end
- # Retrieve the defaults for our type
- hash = getdefaults(objtype, scope)
+ hash = {}
# then set all of the specified params
@params.each { |param|
@@ -105,52 +104,9 @@ class Puppet::Parser::AST
error.backtrace = detail.backtrace
raise error
end
-# else
-# # but things like components create a new type; if we find
-# # one of those, evaluate that with our arguments
-# #Puppet.debug("Calling object '%s' with arguments %s" %
-# # [object.name, hash.inspect])
-# #obj = object.safeevaluate(scope,hash,objtype,objname)
-# obj = object.safeevaluate(
-# :scope => scope,
-# :arguments => hash,
-# :type => objtype,
-# :name => objname
-# )
-#
-# # and pass the result on
-# obj
-# end
}.reject { |obj| obj.nil? }
end
- # Retrieve the defaults for our type
- def getdefaults(objtype, scope)
- # first, retrieve the defaults
- begin
- defaults = scope.lookupdefaults(objtype)
- if defaults.length > 0
- #Puppet.debug "Got defaults for %s: %s" %
- # [objtype,defaults.inspect]
- end
- rescue => detail
- raise Puppet::DevError,
- "Could not lookup defaults for %s: %s" %
- [objtype, detail.to_s]
- end
-
- hash = {}
- # Add any found defaults to our argument list
- defaults.each { |var,value|
- Puppet.debug "Found default %s for %s" %
- [var,objtype]
-
- hash[var] = value
- }
-
- return hash
- end
-
# Create our ObjectDef. Handles type checking for us.
def initialize(hash)
@checked = false
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 1dde7f642..f247bd7b8 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -35,6 +35,20 @@ module Puppet
@@declarative = val
end
+ # Add all of the defaults for a given object to that object.
+ def adddefaults(obj)
+ defaults = self.lookupdefaults(obj.type)
+
+ defaults.each do |var, value|
+ unless obj[var]
+ self.debug "Adding default %s for %s" %
+ [var, obj.type]
+
+ obj[var] = value
+ end
+ end
+ end
+
# Add a single object's tags to the global list of tags for
# that object.
def addtags(obj)
@@ -975,6 +989,9 @@ module Puppet
# probably should not matter
child.tags = self.tags
+ # Add any defaults.
+ self.adddefaults(child)
+
# Then make sure this child's tags are stored in the
# central table. This should maybe be in the evaluate
# methods, but, eh.