summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-01 00:30:07 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-01 00:30:07 +0000
commit76ff83d86ce2bfaea69bb57af766833ea21095a5 (patch)
tree42084c63e524c378dee4390dfd742704cba69418 /lib
parentb08816b000242def032f7099cad2d27310ed389c (diff)
downloadpuppet-76ff83d86ce2bfaea69bb57af766833ea21095a5.tar.gz
puppet-76ff83d86ce2bfaea69bb57af766833ea21095a5.tar.xz
puppet-76ff83d86ce2bfaea69bb57af766833ea21095a5.zip
Fixing #161. Basically, AST::ObjectDef now catches when users specify a name as a parameter instead of the name before the colon and modify the results accordingly. This catches this kind of problem, and the normal name handling picks up everything else.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1229 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/ast/objectdef.rb33
1 files changed, 25 insertions, 8 deletions
diff --git a/lib/puppet/parser/ast/objectdef.rb b/lib/puppet/parser/ast/objectdef.rb
index 7ccc9851a..7ed64388e 100644
--- a/lib/puppet/parser/ast/objectdef.rb
+++ b/lib/puppet/parser/ast/objectdef.rb
@@ -55,23 +55,40 @@ class Puppet::Parser::AST
raise error
end
+ hash = {}
+ # Evaluate all of the specified params.
+ @params.each { |param|
+ ary = param.safeevaluate(:scope => scope)
+ hash[ary[0]] = ary[1]
+ }
+
objnames = [nil]
- # Autogenerate the name if one was not passed.
+ # Determine our name if we have one.
if self.name
objnames = @name.safeevaluate(:scope => scope)
# it's easier to always use an array, even for only one name
unless objnames.is_a?(Array)
objnames = [objnames]
end
- end
+ else
+ # See if they specified the name as a parameter instead of as a
+ # normal name (i.e., before the colon).
+ unless object # we're a builtin
+ if objclass = Puppet::Type.type(objtype)
+ namevar = objclass.namevar
- hash = {}
+ tmp = hash["name"] || hash[namevar.to_s]
- # then set all of the specified params
- @params.each { |param|
- ary = param.safeevaluate(:scope => scope)
- hash[ary[0]] = ary[1]
- }
+ if tmp
+ objnames = [tmp]
+ end
+ else
+ # this should never happen, because we've already
+ # typechecked, but it's no real problem if it does happen.
+ # We just end up with an object with no name.
+ end
+ end
+ end
# this is where our implicit iteration takes place;
# if someone passed an array as the name, then we act