diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-07-11 20:17:59 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-07-11 20:17:59 +0000 |
commit | 73556a8c71ee1f847f498a8b9db8ff810902dfee (patch) | |
tree | 134616e37cb2b30d92af5edbe34a2f9127659939 /lib/puppet | |
parent | 1ec1b9905d0b2f0ba0a0cb3b7dc293ee204cdbc5 (diff) | |
download | puppet-73556a8c71ee1f847f498a8b9db8ff810902dfee.tar.gz puppet-73556a8c71ee1f847f498a8b9db8ff810902dfee.tar.xz puppet-73556a8c71ee1f847f498a8b9db8ff810902dfee.zip |
Fixing templating so it immediately fails when a variable is not found, as opposed to passing up the method_missing heirarchy, which was causing a nasty memory leak and some kind of weird, long-running search
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1389 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parser/scope.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 747645cbc..317776055 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -14,6 +14,7 @@ module Puppet::Parser # the scope objects. class TemplateWrapper attr_accessor :scope, :file + include Puppet::Util Puppet::Util.logmethods(self) def initialize(scope, file) @@ -39,14 +40,21 @@ module Puppet::Parser if value = @scope.lookupvar(name.to_s) and value != :undefined and value != "" return value else - info "Could not find value for %s" % name - return "" + # Just throw an error immediately, instead of searching for + # other missingmethod things or whatever. + raise Puppet::ParseError, + "Could not find value for '%s'" % name end end def result - template = ERB.new(File.read(@file)) - template.result(binding) + result = nil + benchmark(:info, "Interpolated template #{@file}") do + template = ERB.new(File.read(@file)) + result = template.result(binding) + end + + result end def to_s @@ -1102,6 +1110,13 @@ module Puppet::Parser end end + # Undefine a variable; only used for testing. + def unsetvar(var) + if @symtable.include?(var) + @symtable.delete(var) + end + end + protected # This method abstracts recursive searching. It accepts the type |