Class: Ufo::Base

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Stack::Helper
Defined in:
lib/ufo/base.rb

Direct Known Subclasses

Cancel, Destroy, Info, Ps, Releases, Rollback, Scale, Ship, Status, Stop, Task

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(service, options = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'lib/ufo/base.rb', line 6

def initialize(service, options={})
  @service = switch_current(service)
  @options = options

  @cluster = @options[:cluster] || default_cluster(@service)
  @stack_name = adjust_stack_name(@cluster, @service)
end

Instance Method Details

#full_serviceObject



31
32
33
# File 'lib/ufo/base.rb', line 31

def full_service
  [@service, Ufo.env_extra].compact.join("-")
end

#infoObject



18
19
20
# File 'lib/ufo/base.rb', line 18

def info
  Info.new(@service, @options)
end

#no_service_messageObject



23
24
25
26
27
28
29
# File 'lib/ufo/base.rb', line 23

def no_service_message
  <<-EOL
No #{@service.color(:green)} ecs service found.
No CloudFormation stack named #{@stack_name.color(:green)} found.
Are sure it exists?
  EOL
end

#switch_current(service) ⇒ Object



14
15
16
# File 'lib/ufo/base.rb', line 14

def switch_current(service)
  Current.service!(service)
end