On Apr 29, 4:30 am, Krzysztof Wilczynski
I was hoping that I could just simply do a:
How would that be different than using the "in" in your if statement? :)
Or, what is wrong with using if? Unless I am missing something? :)
Nothing is wrong with using if statements per-say.
To put my problem slightly differently, in the module I am working on
I have have five checks that would benefit by having the helper
function (it would be cleaner, easier to maintain and easier to read).
Also I hope that by doing the check purely in ruby it would be
slightly faster to process rather then return a couple of times.
To give you an example within my module in the param's file I have:
$valid_package_ensure_values = [ "present", "installed",
"latest", "absent", "purged", "held" ]
$valid_service_ensure_values = [ "running", "true",
"stopped", "false" ]
$valid_service_enable_values = [ "true", "false", "manual" ]
$valid_module_config_values = [ "file", "template" ]
$valid_module_tpml_loc_values = [ "module", "site" ]
If I had the validate_in helper function and used the other validate
functions in the stdlib the validation code would look like
class module::server::base ( $package_ensure = undef,
$service_ensure = undef,
$service_enable = undef,
$module_config = undef,
$template_loc = undef,
$use_storeconfig = undef,
$proxy_port = undef,
$cache_dir = undef,
$log_dir = undef,
$cache_net_adr = undef
# start using the values in code below
The above code is very easy to read and you could see at a glance
exactly what is happening. Also if the error message follows the
format described in my previous message debugging would be very
simple. I could see myself using the same pattern in other modules I
Bottom line instead of the current 35 lines of validation code I
have, I could replace it with the above 8 lines which would do the
same amount of work (4:1 ratio)!
Funnily enough after I sent the original email I stumbled on
puppetlabs-stdlib/lib/puppet/parser/functions/member.rb which is
almost exactly what I am looking for, I notice that you wrote it ;)
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.