Skip to content

Commit

Permalink
Fix for issue tc#9, Invalid option: --supported-product
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Kincaid committed Apr 27, 2014
1 parent 5ef42c0 commit cea0292
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ def initialize(*args)
super(*args)
@instance_group_commands = []
@bootstrap_commands = []
@supported_product_commands = []
end

def add_step_command(step)
Expand All @@ -1113,6 +1114,10 @@ def add_instance_group_command(instance_group_command)
@instance_group_commands << instance_group_command
end

def add_supported_product_command(supported_product_command)
@supported_product_commands << supported_product_command
end

def validate
for step in step_commands do
if step.is_a?(EnableDebuggingCommand) then
Expand Down Expand Up @@ -1267,6 +1272,23 @@ def default_job_flow_name
end
end

class SupportedProductCommand < Command
attr_accessor :name, :args

def initialize(*args)
super(*args)
@args = []
end

def supported_product()
product = {
"Name" => @arg,
"Args" => @args
}
return product
end
end

class BootstrapActionCommand < Command
attr_accessor :bootstrap_name, :args

Expand Down Expand Up @@ -1782,7 +1804,7 @@ def self.add_commands(commands, opts)

opts.separator "\n Passing arguments to steps\n"

commands.parse_options(step_commands + ["--bootstrap-action", "--stream"], [
commands.parse_options(step_commands + ["--bootstrap-action", "--stream", "--supported-product"], [
[ ArgsOption, "--args ARGS", "A command separated list of arguments to pass to the step" ],
[ ArgOption, "--arg ARG", "An argument to pass to the step" ],
[ OptionWithArg, "--step-name STEP_NAME", "Set name for the step", :step_name ],
Expand Down Expand Up @@ -1912,6 +1934,9 @@ def self.add_commands(commands, opts)
[ GlobalOption, "--key-pair-file FILE_PATH", "Path to your local pem file for your EC2 key pair", :key_pair_file ],
])

opts.separator "\n Specifying Supported Products\n"
commands.parse_command(SupportedProductCommand, "--supported-product NAME", "Install a supported product")

opts.separator "\n Specifying Bootstrap Actions\n"

commands.parse_command(BootstrapActionCommand, "--bootstrap-action SCRIPT", "Run a bootstrap action script on all instances")
Expand Down Expand Up @@ -1993,6 +2018,7 @@ def self.is_create_child_command(cmd)
return is_step_command(cmd) ||
is_ba_command(cmd) ||
cmd.is_a?(AddInstanceGroupCommand) ||
cmd.is_a?(SupportedProductCommand) ||
cmd.is_a?(CreateInstanceGroupCommand)
end

Expand All @@ -2014,6 +2040,8 @@ def self.fold_commands(commands)
raise RuntimeError, "the option #{cmd.name} must come after the --create option"
elsif cmd.is_a?(CreateInstanceGroupCommand) then
raise RuntimeError, "the option #{cmd.name} must come after the --create option"
elsif cmd.is_a?(SupportedProductCommand) then
raise RuntimeError, "the option #{cmd.name} must come after the --create option"
elsif cmd.is_a?(AddInstanceGroupCommand) then
new_commands << cmd
next
Expand All @@ -2039,6 +2067,10 @@ def self.fold_commands(commands)
last_create_command.add_bootstrap_command(cmd)
actioned = true
end
if cmd.is_a?(SupportedProductCommand) then
last_create_command.add_supported_product_command(cmd)
actioned = true
end
if cmd.is_a?(CreateInstanceGroupCommand) || cmd.is_a?(AddInstanceGroupCommand) then
if last_create_command.respond_to?(:add_instance_group_command) then
last_create_command.add_instance_group_command(cmd)
Expand Down

0 comments on commit cea0292

Please sign in to comment.