Class: Mikoshi::Plan::TaskDefinition

Inherits:
Base
  • Object
show all
Defined in:
lib/mikoshi/plan/task_definition.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #data

Instance Method Summary collapse

Methods inherited from Base

#invoke_hooks

Constructor Details

#initialize(yaml_path: nil, client: nil) ⇒ TaskDefinition

Returns a new instance of TaskDefinition.



8
9
10
# File 'lib/mikoshi/plan/task_definition.rb', line 8

def initialize(yaml_path: nil, client: nil)
  super
end

Instance Method Details

#register_task_definitionObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mikoshi/plan/task_definition.rb', line 12

def register_task_definition
  invoke_before_register_hooks

  resp = @client.register_task_definition(@data[:task_definition])
  ENV['TASK_DEF_REVISION'] = resp.task_definition.revision.to_s

  invoke_after_register_hooks

  resp
rescue StandardError => e
  invoke_failed_hooks
  raise e
end

#runtask(cluster: nil) ⇒ Object

Raises:

  • (ArgumentError)


26
27
28
29
30
31
# File 'lib/mikoshi/plan/task_definition.rb', line 26

def runtask(cluster: nil)
  raise ArgumentError, 'cluster name is required.' if cluster.nil?

  resp = @client.register_task_definition(@data[:task_definition])
  @client.run_task(task_definition: resp[:task_definition][:task_definition_arn], cluster: cluster)
end