diff options
author | Luke Kanies <luke@madstop.com> | 2009-09-19 21:33:34 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-22 09:27:23 +1000 |
commit | d42bda1f22e3beca321700a78aab9c1399537c30 (patch) | |
tree | 349803fab5e39eb2425a575e43de4a10ca6c3a37 /lib/puppet/parser | |
parent | d53bc169861815ce7cffac431f76304c995bb4fa (diff) | |
download | puppet-d42bda1f22e3beca321700a78aab9c1399537c30.tar.gz puppet-d42bda1f22e3beca321700a78aab9c1399537c30.tar.xz puppet-d42bda1f22e3beca321700a78aab9c1399537c30.zip |
Fixing relationship metaparam backward compatibility
We broke some cases of metaparam compatibility in 0.25.
Most of it was pretty esoteric, but one thing that wasn't working
was relationship metaparams specified on defined resources.
This adds a compatibility method for older clients.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/resource.rb | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 7218ac0c0..29b1fb1ac 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -17,7 +17,7 @@ class Puppet::Parser::Resource include Puppet::Parser::YamlTrimmer attr_accessor :source, :scope, :rails_id - attr_accessor :virtual, :override, :translated + attr_accessor :virtual, :override, :translated, :catalog attr_reader :exported, :evaluated, :params @@ -304,23 +304,42 @@ class Puppet::Parser::Resource end end + def add_backward_compatible_relationship_param(name) + # Skip metaparams for which we get no value. + return unless val = scope.lookupvar(name.to_s, false) and val != :undefined + + # The default case: just set the value + set_parameter(name, val) and return unless @params[name] + + # For relationship params, though, join the values (a la #446). + @params[name].value = [@params[name].value, val].flatten + end + # Add any metaparams defined in our scope. This actually adds any metaparams # from any parent scope, and there's currently no way to turn that off. def add_metaparams + compat_mode = metaparam_compatibility_mode? + Puppet::Type.eachmetaparam do |name| - next if self.class.relationship_parameter?(name) - # Skip metaparams that we already have defined, unless they're relationship metaparams. - # LAK:NOTE Relationship metaparams get treated specially -- we stack them, instead of - # overriding. + if self.class.relationship_parameter?(name) + add_backward_compatible_relationship_param(name) if compat_mode + next + end + next if @params[name] # Skip metaparams for which we get no value. next unless val = scope.lookupvar(name.to_s, false) and val != :undefined - set_parameter(name, val) and next unless @params[name] + set_parameter(name, val) end end + # Unless we're running >= 0.25, we're in compat mode. + def metaparam_compatibility_mode? + ! (catalog and version = catalog.client_version and version = version.split(".") and version[0] == "0" and version[1].to_i >= 25) + end + def add_scope_tags if scope_resource = scope.resource tag(*scope_resource.tags) |