diff options
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/ast/component.rb | 22 | ||||
-rw-r--r-- | lib/puppet/parser/resource.rb | 7 |
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb index 8f82d530a..9e3179edb 100644 --- a/lib/puppet/parser/ast/component.rb +++ b/lib/puppet/parser/ast/component.rb @@ -28,13 +28,15 @@ class Puppet::Parser::AST def evaluate(hash) origscope = hash[:scope] objtype = hash[:type] - name = hash[:name] + title = hash[:title] args = symbolize_options(hash[:arguments] || {}) + name = args[:name] || title + exported = hash[:exported] pscope = origscope - scope = subscope(pscope, name) + scope = subscope(pscope, title) if exported or origscope.exported? scope.exported = true @@ -46,8 +48,10 @@ class Puppet::Parser::AST scope.tag(@type) end - unless name.nil? or name =~ /[^\w]/ or name == "" - scope.tag(name) + [name, title].each do |str| + unless str.nil? or str =~ /[^\w]/ or str == "" + scope.tag(str) + end end # define all of the arguments in our local scope @@ -66,7 +70,7 @@ class Puppet::Parser::AST # [default.inspect, arg.inspect, @name.inspect] else parsefail "Must pass %s to %s of type %s" % - [arg,name,@type] + [arg,title,@type] end end } @@ -84,7 +88,11 @@ class Puppet::Parser::AST end } - unless args.include? "name" + unless args.include? :title + scope.setvar("title",title) + end + + unless args.include? :name scope.setvar("name",name) end @@ -192,6 +200,8 @@ class Puppet::Parser::AST if @arguments.include?(param) # It's a valid arg for us return true + elsif param == "name" + return true # elsif defined? @parentclass and @parentclass # # Else, check any existing parent # if parent = @scope.lookuptype(@parentclass) and parent != [] diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 31d43bd18..bdace28cd 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -91,7 +91,7 @@ class Puppet::Parser::Resource scope.deleteresource(self) return klass.evaluate(:scope => scope, :type => self.type, - :name => self.title, + :title => self.title, :arguments => self.to_hash, :scope => self.scope, :exported => self.exported @@ -182,16 +182,17 @@ class Puppet::Parser::Resource # Verify that all passed parameters are valid. This throws an error if there's # a problem, so we don't have to worry about the return value. def paramcheck(param) + param = param.to_s # Now make sure it's a valid argument to our class. These checks # are organized in order of commonhood -- most types, it's a valid argument # and paramcheck is enabled. if @ref.typeclass.validattr?(param) true - elsif (param == "name" or param == "title") # always allow these + elsif %w{name title}.include?(param) # always allow these true elsif paramcheck? self.fail Puppet::ParseError, "Invalid parameter '%s' for type '%s'" % - [param, @ref.type] + [param.inspect, @ref.type] end end |