diff options
author | Luke Kanies <luke@madstop.com> | 2008-09-23 22:31:55 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-09-23 22:31:55 -0500 |
commit | 4aeabbbb2163684ff7064198c653cd60d46e5717 (patch) | |
tree | 7c3593bde6b7f28f3e20444a576eb37338cced14 /lib/puppet/parser/scope.rb | |
parent | 5b9dd01326a61b9ae89ae978e29a8170f76deb5e (diff) | |
parent | 8d5ded09b9c9c944695c015e6e95b10ccebd6fb5 (diff) | |
download | puppet-4aeabbbb2163684ff7064198c653cd60d46e5717.tar.gz puppet-4aeabbbb2163684ff7064198c653cd60d46e5717.tar.xz puppet-4aeabbbb2163684ff7064198c653cd60d46e5717.zip |
Merge branch '0.24.x'
Conflicts:
lib/puppet/metatype/container.rb
lib/puppet/metatype/instances.rb
lib/puppet/metatype/metaparams.rb
lib/puppet/metatype/relationships.rb
lib/puppet/metatype/schedules.rb
Diffstat (limited to 'lib/puppet/parser/scope.rb')
-rw-r--r-- | lib/puppet/parser/scope.rb | 26 |
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. |