Class: Ufo::Apps

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Stack::Helper
Defined in:
lib/ufo/apps.rb,
lib/ufo/apps/cfn_map.rb,
lib/ufo/apps/service.rb

Defined Under Namespace

Classes: CfnMap, Service

Instance Method Summary collapse

Methods included from Stack::Helper

#adjust_stack_name, #cfn, #find_stack, #status

Methods included from Util

#default_cluster, #display_params, #execute, #pretty_time, #settings, #task_definition_arns, #user_params

Methods included from AwsService

#cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb

Constructor Details

#initialize(options) ⇒ Apps

Returns a new instance of Apps.



11
12
13
14
# File 'lib/ufo/apps.rb', line 11

def initialize(options)
  @options = options
  @cluster = @options[:cluster] || default_cluster
end

Instance Method Details

#display_info(resp) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/ufo/apps.rb', line 35

def display_info(resp)
  table = Text::Table.new
  table.head = ["Service Name", "Task Definition", "Running", "Launch type", "Ufo?"]
  resp["services"].each do |s|
    table.rows << service_info(s)
  end
  puts table unless ENV['TEST']
end

#listObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ufo/apps.rb', line 16

def list
  begin
    resp = ecs.list_services(cluster: @cluster)
  rescue Aws::ECS::Errors::ClusterNotFoundException => e
    puts "ECS cluster #{@cluster.color(:green)} not found."
    exit 1
  end
  arns = resp.service_arns.sort

  puts "Listing ECS services in the #{@cluster.color(:green)} cluster."
  if arns.empty?
    puts "No ECS services found in the #{@cluster.color(:green)} cluster."
    return
  end

  resp = ecs.describe_services(services: arns, cluster: @cluster)
  display_info(resp)
end

#service_info(s) ⇒ Object

for specs



45
46
47
# File 'lib/ufo/apps.rb', line 45

def service_info(s)
  Service.new(s, @options).to_a
end