Class: EcsDeployCli::DSL::Container
- Inherits:
-
Object
- Object
- EcsDeployCli::DSL::Container
show all
- Includes:
- AutoOptions
- Defined in:
- lib/ecs_deploy_cli/dsl/container.rb
Instance Method Summary
collapse
#_options, #method_missing
Constructor Details
#initialize(name, config) ⇒ Container
Returns a new instance of Container.
10
11
12
13
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 10
def initialize(name, config)
@config = config
_options[:name] = name.to_s
end
|
Instance Method Details
#as_definition ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 57
def as_definition
{
cpu: 0,
mount_points: [],
port_mappings: [],
volumes_from: [],
memory_reservation: nil,
essential: true
}.merge(_options)
end
|
#cloudwatch_logs(value) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 46
def cloudwatch_logs(value)
_options[:log_configuration] = {
log_driver: 'awslogs',
options: {
'awslogs-group' => "/ecs/#{value}",
'awslogs-stream-prefix' => 'ecs',
'awslogs-region' => @config[:aws_region]
}
}
end
|
#command(*command) ⇒ Object
15
16
17
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 15
def command(*command)
_options[:command] = command
end
|
#env(key:, value:) ⇒ Object
23
24
25
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 23
def env(key:, value:)
(_options[:environment] ||= []) << { name: key, value: value }
end
|
#expose(**options) ⇒ Object
31
32
33
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 31
def expose(**options)
(_options[:port_mappings] ||= []) << options
end
|
#load_envs(name) ⇒ Object
19
20
21
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 19
def load_envs(name)
_options[:environment] = (_options[:environment] || []) + YAML.safe_load(File.open(name), symbolize_names: true)
end
|
#memory(limit:, reservation:) ⇒ Object
35
36
37
38
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 35
def memory(limit:, reservation:)
_options[:memory] = limit
_options[:memory_reservation] = reservation
end
|
#merge(other) ⇒ Object
40
41
42
43
44
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 40
def merge(other)
other_options = other._options
other_options.delete(:name)
_options.merge!(other_options)
end
|
#secret(key:, value:) ⇒ Object
27
28
29
|
# File 'lib/ecs_deploy_cli/dsl/container.rb', line 27
def secret(key:, value:)
(_options[:secrets] ||= []) << { name: key, value_from: "arn:aws:ssm:#{@config[:aws_region]}:#{@config[:aws_profile_id]}:parameter/#{value}" }
end
|