summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/scope.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-09-27 21:30:49 +0200
committerLuke Kanies <luke@madstop.com>2008-09-27 21:30:49 +0200
commitb96bdc6a63f7be6b724c2aa7ad0ea007cba81718 (patch)
tree6d334ea12e1468b34160fa36da29dd7d78ac31ea /lib/puppet/parser/scope.rb
parente20f02af4a93478c5b08b7681caa12cd72b4a3a6 (diff)
parent3749267093923692d6e7bc0c9ce83b43a487b19e (diff)
downloadpuppet-b96bdc6a63f7be6b724c2aa7ad0ea007cba81718.tar.gz
puppet-b96bdc6a63f7be6b724c2aa7ad0ea007cba81718.tar.xz
puppet-b96bdc6a63f7be6b724c2aa7ad0ea007cba81718.zip
Merge branch '0.24.x' of git://github.com/jamtur01/puppet into 0.24.x
Diffstat (limited to 'lib/puppet/parser/scope.rb')
-rw-r--r--lib/puppet/parser/scope.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 32b127a6b..1ff998d96 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -260,11 +260,15 @@ class Puppet::Parser::Scope
# Set a variable in the current scope. This will override settings
# in scopes above, but will not allow variables in the current scope
# to be reassigned.
- def setvar(name,value, file = nil, line = nil)
- #Puppet.debug "Setting %s to '%s' at level %s" %
- # [name.inspect,value,self.level]
+ def setvar(name,value, file = nil, line = nil, append = false)
+ #Puppet.debug "Setting %s to '%s' at level %s mode append %s" %
+ # [name.inspect,value,self.level, append]
if @symtable.include?(name)
- error = Puppet::ParseError.new("Cannot reassign variable %s" % name)
+ unless append
+ error = Puppet::ParseError.new("Cannot reassign variable %s" % name)
+ else
+ error = Puppet::ParseError.new("Cannot append, variable %s is defined in this scope" % name)
+ end
if file
error.file = file
end
@@ -273,7 +277,19 @@ class Puppet::Parser::Scope
end
raise error
end
- @symtable[name] = value
+
+ unless append
+ @symtable[name] = value
+ else # append case
+ # lookup the value in the scope if it exists and insert the var
+ @symtable[name] = lookupvar(name)
+ # concatenate if string, append if array, nothing for other types
+ if value.is_a?(Array)
+ @symtable[name] += value
+ else
+ @symtable[name] << value
+ end
+ end
end
# Return an interpolated string.