Issue #4113 has been updated by Stefan Schulte.

I agree with Daniel here. The basic sketch I have in mind

1. the type parses all parameters and properties.
2. parameters not valid for that type should be passed to the provider which 
can a) store the value somewhere b) do value validation
3. parameters that are passed to the provider and are not valid for that 
provider are passed back to the type. The type should now raise an exception

in `lib/puppet/type.rb` this could look something like:
<pre>
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 3c0cb1b..cdbb29f 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1776,13 +1776,17 @@ class Type
     # extra attributes from the resource so we get failures
     # on invalid attributes.
     no_values = []
+    invalid_parameters = {}
     (self.class.allattrs + hash.keys).uniq.each do |attr|
       begin
         # Set any defaults immediately.  This is mostly done so
         # that the default provider is available for any other
         # property validation.
         if hash.has_key?(attr)
-          self[attr] = hash[attr]
+          if self.class.validattr?(attr)
+            self[attr] = hash[attr]
+          else
+            invalid_parameters[attr]= hash[attr]
         else
           no_values << attr
         end
@@ -1797,6 +1801,12 @@ class Type
     no_values.each do |attr|
       set_default(attr)
     end
+    if !invalid_paramters.empty? and provider and provider.respond_to? 
:set_parameters
+      invalid_parameters = provider.set_parameters(invalid_parameters)
+    end
+    invalid_parameters.keys.each do |name|
+      fail("Invalid parameter #{name}")
+    end
   end
</pre>
----------------------------------------
Feature #4113: Provide a generic "options"-style parameter for packages.
https://projects.puppetlabs.com/issues/4113

Author: Oliver Hookins
Status: Accepted
Priority: Normal
Assignee: Jacob Helwig
Category: 
Target version: Telly
Affected Puppet version: 0.25.5
Keywords: 
Branch: 


http://groups.google.com/group/puppet-users/browse_thread/thread/2ef615fc42225d99?pli=1

Our requirement is more or less the same as in the linked thread, we need to 
use a proxy to install gems but for a variety of reasons can't set a global 
proxy on the machines. Thus some way of passing options to gem is necessary.

(Nigel) - We should do this consistently across providers, perhaps combining 
with the "preseed" functionality of apt/dpkg.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to