Issue #8300 has been updated by Jeff McCune.
Pieter van de Bruggen wrote: > The #before_action call is used to validate, coerce, and mutate options that > have been passed. > > The #required call is used to specify that the option must be supplied. > > The validation implied by #required is invoked before the #before_action call. > > Is there some element of your question I've missed? I don't think so. Could you please confirm that it's expected behavior that the #before_action should not execute if the option's flag is not present on the command line? For example, if I don't pass --platform after the action on the command line, I shouldn't expect the before_action to fire at all, right? If this is the case, I think it makes it difficult to set a "default value" for the option using the #before_action block. See what I'm driving at? -Jeff ---------------------------------------- Bug #8300: Option validation does not appear to be workin when run from the command line https://projects.puppetlabs.com/issues/8300 Author: Jeff McCune Status: Needs More Information Priority: Normal Assignee: Category: Target version: Keywords: Branch: # Overview # Working on #8265 I'm running into the situation where not supplying a --platform option results in a nil value being passed directly to Fog. For example, the following section of code does not seem to be evaluated: <pre> # lib/puppet/cloudpack.rb 7 def add_platform_option(action) 8 action.option '--platform=' do 9 before_action do |action, args, options| 10 supported_platforms = [ 'AWS' ] 11 unless supported_platforms.include?(options[:platform]) 12 raise ArgumentError, "Platform must be one of the following: #{supported_platforms.join(', ')}" 13 end 14 end 15 end 16 end </pre> Instead, the error I'm getting flows all the way through to: <pre> 337 def create_connection(options = {}) 338 Fog::Compute.new(:provider => options[:platform]) 339 end </pre> I set a breakpoint at line 10 above in the call to `supported_platforms = [ 'AWS' ]` and this line was never evaluated in the debugger. -Jeff -- 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.
