diff options
author | Luke Kanies <luke@madstop.com> | 2008-12-12 18:18:39 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-12-18 11:10:23 -0600 |
commit | f69ac9fdb916787530fb70f00006fa64952a8d45 (patch) | |
tree | 3c8a6360790c264740d3e002528b7ba23ef4029a /lib/puppet | |
parent | 352d7be1a2d3ec6a5930aa4c19c5451e63fdab2e (diff) | |
download | puppet-f69ac9fdb916787530fb70f00006fa64952a8d45.tar.gz puppet-f69ac9fdb916787530fb70f00006fa64952a8d45.tar.xz puppet-f69ac9fdb916787530fb70f00006fa64952a8d45.zip |
Setting resource defaults immediately.
This makes it easier for later parameters to depend on the values
of earlier parameters.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parameter.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type.rb | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index 5f68d44a5..04b3aec30 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -496,7 +496,7 @@ class Puppet::Parameter # Retrieve the resource's provider. Some types don't have providers, in which # case we return the resource object itself. def provider - @resource.provider || @resource + @resource.provider end def to_s diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index f4d3d9de8..5739b369e 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1987,9 +1987,16 @@ class Type found = [] (self.class.allattrs + resource.keys).uniq.each do |attr| - next unless resource.has_key?(attr) + begin - self[attr] = resource[attr] + # Set any defaults immediately. This is mostly done so + # that the default provider is available for any other + # property validation. + if resource.has_key?(attr) + self[attr] = resource[attr] + else + setdefaults(attr) + end rescue ArgumentError, Puppet::Error, TypeError raise rescue => detail @@ -1998,9 +2005,6 @@ class Type raise error end end - - # Set all default values. - self.setdefaults self.validate if self.respond_to?(:validate) end |