Class: ContainerShip::TaskDefinition
- Inherits:
-
Object
- Object
- ContainerShip::TaskDefinition
- Defined in:
- lib/container_ship/task_definition.rb
Instance Attribute Summary collapse
-
#build_number ⇒ Object
readonly
Returns the value of attribute build_number.
-
#cluster_name ⇒ Object
readonly
Returns the value of attribute cluster_name.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #full_cluster_name ⇒ Object
- #full_name ⇒ Object
- #image_name ⇒ Object
-
#initialize(cluster_name, type, name, environment, build_number) ⇒ TaskDefinition
constructor
A new instance of TaskDefinition.
- #log_group_name ⇒ Object
- #log_stream_name(task_arn) ⇒ Object
- #run_task_options ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(cluster_name, type, name, environment, build_number) ⇒ TaskDefinition
Returns a new instance of TaskDefinition.
7 8 9 10 11 12 13 |
# File 'lib/container_ship/task_definition.rb', line 7 def initialize(cluster_name, type, name, environment, build_number) @cluster_name = cluster_name @type = type @name = name @environment = environment @build_number = build_number end |
Instance Attribute Details
#build_number ⇒ Object (readonly)
Returns the value of attribute build_number.
5 6 7 |
# File 'lib/container_ship/task_definition.rb', line 5 def build_number @build_number end |
#cluster_name ⇒ Object (readonly)
Returns the value of attribute cluster_name.
5 6 7 |
# File 'lib/container_ship/task_definition.rb', line 5 def cluster_name @cluster_name end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'lib/container_ship/task_definition.rb', line 5 def environment @environment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/container_ship/task_definition.rb', line 5 def name @name end |
Instance Method Details
#full_cluster_name ⇒ Object
27 28 29 |
# File 'lib/container_ship/task_definition.rb', line 27 def full_cluster_name "#{@cluster_name}-#{@environment}" end |
#full_name ⇒ Object
31 32 33 |
# File 'lib/container_ship/task_definition.rb', line 31 def full_name "#{@cluster_name}-#{@name}-#{@environment}" end |
#image_name ⇒ Object
35 36 37 |
# File 'lib/container_ship/task_definition.rb', line 35 def image_name ENV.fetch('ECR_REPOSITORY') + full_cluster_name end |
#log_group_name ⇒ Object
39 40 41 42 43 |
# File 'lib/container_ship/task_definition.rb', line 39 def log_group_name return nil unless main_container_definition.dig(:log_configuration, :log_driver).to_s == 'awslogs' main_container_definition.dig(:log_configuration, :options, :'awslogs-group') end |
#log_stream_name(task_arn) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/container_ship/task_definition.rb', line 45 def log_stream_name(task_arn) return nil unless main_container_definition.dig(:log_configuration, :log_driver).to_s == 'awslogs' prefix = main_container_definition.dig(:log_configuration, :options, :'awslogs-stream-prefix') "#{prefix}/#{full_name}/#{task_arn.split('/').last}" end |
#run_task_options ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/container_ship/task_definition.rb', line 52 def @run_task_options ||= if File.exist?() JSON.parse(File.read(), symbolize_names: true) else {} end end |
#to_h ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/container_ship/task_definition.rb', line 15 def to_h task_definition_hash .merge( family: full_name, container_definitions: task_definition_hash[:container_definitions].map do |d| next d unless d[:essential] d.merge(name: full_name, image: "#{image_name}:#{@build_number}") end ) end |