diff options
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/ast/boolean_operator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/collector.rb | 22 | ||||
-rw-r--r-- | lib/puppet/parser/functions/generate.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/functions/require.rb | 5 | ||||
-rw-r--r-- | lib/puppet/parser/functions/versioncmp.rb | 2 | ||||
-rw-r--r-- | lib/puppet/parser/resource.rb | 6 |
6 files changed, 29 insertions, 14 deletions
diff --git a/lib/puppet/parser/ast/boolean_operator.rb b/lib/puppet/parser/ast/boolean_operator.rb index 160e0e69e..89725d73b 100644 --- a/lib/puppet/parser/ast/boolean_operator.rb +++ b/lib/puppet/parser/ast/boolean_operator.rb @@ -20,14 +20,14 @@ class Puppet::Parser::AST # return result # lazy evaluate right operand case @operator - when "and"; + when "and" if Puppet::Parser::Scope.true?(lval) rval = @rval.safeevaluate(scope) Puppet::Parser::Scope.true?(rval) else # false and false == false false end - when "or"; + when "or" if Puppet::Parser::Scope.true?(lval) true else diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index a7f81b4e7..a6763c419 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -102,18 +102,24 @@ class Puppet::Parser::Collector raise Puppet::DevError, "Cannot collect resources for a nil host" unless @scope.host host = Puppet::Rails::Host.find_by_name(@scope.host) - query = {:include => {:param_values => :param_name}} - search = "(exported=? AND restype=?)" values = [true, @type] search += " AND (%s)" % @equery if @equery - # this is a small performance optimisation - # the tag mechanism involves 3 more joins, which are - # needed only if we query on tags. - if search =~ /puppet_tags/ - query[:include][:puppet_tags] = :resource_tags + # note: + # we're not eagerly including any relations here because + # it can creates so much objects we'll throw out later. + # We used to eagerly include param_names/values but the way + # the search filter is built ruined those efforts and we + # were eagerly loading only the searched parameter and not + # the other ones. + query = {} + case search + when /puppet_tags/ + query = {:joins => {:resource_tags => :puppet_tag}} + when /param_name/ + query = {:joins => {:param_values => :param_name}} end # We're going to collect objects from rails, but we don't want any @@ -139,7 +145,7 @@ class Puppet::Parser::Collector # and such, we'll need to vary the conditions, but this works with no # attributes, anyway. time = Puppet::Util.thinmark do - Puppet::Rails::Resource.find(:all, @type, true, query).each do |obj| + Puppet::Rails::Resource.find(:all, query).each do |obj| if resource = exported_resource(obj) count += 1 resources << resource diff --git a/lib/puppet/parser/functions/generate.rb b/lib/puppet/parser/functions/generate.rb index 1be9016ed..18fe883b4 100644 --- a/lib/puppet/parser/functions/generate.rb +++ b/lib/puppet/parser/functions/generate.rb @@ -1,7 +1,7 @@ # Runs an external command and returns the results Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue, - :doc => "Calls an external command and returns the results of the - command. Any arguments are passed to the external command as + :doc => "Calls an external command on the Puppet master and returns + the results of the command. Any arguments are passed to the external command as arguments. If the generator does not exit with return code of 0, the generator is considered to have failed and a parse error is thrown. Generators can only have file separators, alphanumerics, dashes, diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb index 3a2032d7f..d72169af5 100644 --- a/lib/puppet/parser/functions/require.rb +++ b/lib/puppet/parser/functions/require.rb @@ -27,7 +27,10 @@ Note that this function only works with clients 0.25 and later, and it will fail if used with earlier clients. ") do |vals| - send(:function_include, vals) + # Verify that the 'include' function is loaded + method = Puppet::Parser::Functions.function(:include) + + send(method, vals) if resource.metaparam_compatibility_mode? warning "The 'require' function is only compatible with clients at 0.25 and above; including class but not adding dependency" else diff --git a/lib/puppet/parser/functions/versioncmp.rb b/lib/puppet/parser/functions/versioncmp.rb index bdf539127..9435655a7 100644 --- a/lib/puppet/parser/functions/versioncmp.rb +++ b/lib/puppet/parser/functions/versioncmp.rb @@ -18,7 +18,7 @@ This functions returns a number:: Example:: if versioncmp('2.6-1', '2.4.5') > 0 { - notify('2.6-1 is > than 2.4.5') + notice('2.6-1 is > than 2.4.5') } ") do |args| diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index b8aaf2715..651ed4224 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -139,6 +139,12 @@ class Puppet::Parser::Resource if params = options[:params] options.delete(:params) params.each do |param| + # Don't set the same parameter twice + if @params[param.name] + self.fail Puppet::ParseError, "Duplicate parameter '%s' for on %s" % + [param.name, self.to_s] + end + set_parameter(param) end end |