Issue #8300 has been updated by Jeff McCune.

# Question for Daniel / Pieter #

Daniel, Pieter or any of the other devs.

In the the following code the options are being passed to the underlying 
create_connection() method without an error being thrown that the --platform 
option is required when the end user does not specify the --platform flag on 
the command line invocation.  Please note that the validation DOES happen if 
--platform is provided with no following value.

Is this a bug or does the required keyword not do what I think it does?

<pre>
# cloudpack/lib/puppet/cloudpack.rb
    def add_platform_option(action)
      action.option '--platform=' do
        required
        before_action do |action, args, options|
          supported_platforms = [ 'AWS' ]
          unless supported_platforms.include?(options[:platform])
            raise ArgumentError, "Platform must be one of the following: 
#{supported_platforms.join(', ')}"
          end
        end
      end
    end
</pre>
----------------------------------------
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.

Reply via email to