lib/mikoshi/cli.rb in mikoshi-0.5.1 vs lib/mikoshi/cli.rb in mikoshi-0.6.0
- old
+ new
@@ -33,10 +33,12 @@
case @options[:command]
when :update_task_definition
update_task_definition(@options[:config][:task_definition] || @argv[1])
when :update_service
update_service(@options[:config][:service] || @argv[1])
+ when :runtask
+ runtask(@options[:config][:task_definition] || @argv[1], @options[:config][:cluster])
when :deploy
deploy
when :version
version
when :help
@@ -52,10 +54,11 @@
opt.on('-t', '--task-definition=TASK_DEFINITION') { |v| @options[:config][:task_definition] = v }
opt.on('--potdr') { |v| @options[:config][:potdr] = v }
opt.on('-g', '--group=GROUP') { |v| @options[:config][:group] = v }
opt.on('-h', '--help') { |v| @options[:config][:help] = v }
opt.on('-v', '--version') { |v| @options[:config][:version] = v }
+ opt.on('--cluster=CLUSTER') { |v| @options[:config][:cluster] = v }
opt.permute!(@argv)
@options[:command] = @argv.first.to_sym unless @argv.first.nil?
end
@@ -81,10 +84,17 @@
Option
--potdr
Acronym of the "Print Only Task Definition Revision".
+ runtask
+ Invoke new task using specified task definition.
+
+ Option
+ --cluster
+ Set cluster to run task. (required)
+
update_service
Update service to given service yaml file.
Wait for success to update the service. (Maximum 300 min)
deploy
@@ -121,9 +131,25 @@
puts "Update task definition: #{task_def_name}" unless potdr
task.register_task_definition
puts "Done update task definition: #{task_def_name} revision: #{ENV['TASK_DEF_REVISION']}" unless potdr
puts ENV['TASK_DEF_REVISION'] if potdr
+ end
+
+ def runtask(task_def_name, cluster)
+ if task_def_name.nil?
+ warn '--task-definition=TASK_DEFINITION is require option.'
+ abort
+ end
+
+ task = ::Mikoshi::Plan::TaskDefinition.new(
+ yaml_path: File.join(TASK_DEFINITION_PATH, task_def_name + PLAN_EXT),
+ client: aws_client,
+ )
+
+ puts "Run task: #{task_def_name}"
+ task.runtask(cluster: cluster)
+ puts "Invoked task: #{task_def_name}"
end
def update_service(service_name)
if service_name.nil?
warn '--service=SERVICE is require option.'