Class: EcsDeployCli::DSL::Task

Inherits:
Object
  • Object
show all
Includes:
AutoOptions
Defined in:
lib/ecs_deploy_cli/dsl/task.rb

Instance Method Summary collapse

Methods included from AutoOptions

#_options, #method_missing

Constructor Details

#initialize(name, config) ⇒ Task

Returns a new instance of Task.



10
11
12
13
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 10

def initialize(name, config)
  @config = config
  _options[:family] = name.to_s
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EcsDeployCli::DSL::AutoOptions

Instance Method Details

#as_definition(containers) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 39

def as_definition(containers)
  {
    container_definitions: containers.values_at(*@containers),
    execution_role_arn: "arn:aws:iam::#{@config[:aws_profile_id]}:role/ecsTaskExecutionRole",
    requires_compatibilities: ['EC2'],
    placement_constraints: [],
    cpu: @cpu,
    memory: @memory,
    volumes: [],
    network_mode: nil
  }.merge(_options)
end

#containers(*containers) ⇒ Object



15
16
17
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 15

def containers(*containers)
  @containers = containers
end

#cpu(value) ⇒ Object



19
20
21
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 19

def cpu(value)
  @cpu = value.to_s
end

#execution_role(name) ⇒ Object



35
36
37
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 35

def execution_role(name)
  _options[:execution_role_arn] = "arn:aws:iam::#{@config[:aws_profile_id]}:role/#{name}"
end

#memory(value) ⇒ Object



23
24
25
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 23

def memory(value)
  @memory = value.to_s
end

#tag(key, value) ⇒ Object



27
28
29
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 27

def tag(key, value)
  (_options[:tags] ||= []) << { key: key, value: value }
end

#volume(value) ⇒ Object



31
32
33
# File 'lib/ecs_deploy_cli/dsl/task.rb', line 31

def volume(value)
  (_options[:volumes] ||= []) << value
end