Class: ECSHelper::ServiceHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_helper/service_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(helper) ⇒ ServiceHelper

Returns a new instance of ServiceHelper.



6
7
8
# File 'lib/ecs_helper/service_helper.rb', line 6

def initialize(helper)
  @helper = helper
end

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



4
5
6
# File 'lib/ecs_helper/service_helper.rb', line 4

def cluster
  @cluster
end

#current_serviceObject

Returns the value of attribute current_service.



4
5
6
# File 'lib/ecs_helper/service_helper.rb', line 4

def current_service
  @current_service
end

#helperObject

Returns the value of attribute helper.



4
5
6
# File 'lib/ecs_helper/service_helper.rb', line 4

def helper
  @helper
end

#servicesObject

Returns the value of attribute services.



4
5
6
# File 'lib/ecs_helper/service_helper.rb', line 4

def services
  @services
end

Instance Method Details

#from_envObject



25
26
27
# File 'lib/ecs_helper/service_helper.rb', line 25

def from_env
  services.find {|s| s.include?(helper.application) && s.include?(helper.environment)}
end

#from_optionsObject

Raises:

  • (StandardError)


18
19
20
21
22
23
# File 'lib/ecs_helper/service_helper.rb', line 18

def from_options
  value = helper.options[:service]
  return nil unless value
  return value if services.include?(value)
  raise(StandardError.new("Service specified in cli not exists, services you have: #{services}")) unless services.find {|r| r == value}
end

#only_oneObject



29
30
31
# File 'lib/ecs_helper/service_helper.rb', line 29

def only_one
  return services[0] if services.length == 1
end

#update_service(cluster, service, task_definition) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/ecs_helper/service_helper.rb', line 33

def update_service(cluster, service, task_definition)
  helper.client.update_service({
    cluster: cluster,
    service: service,
    task_definition: task_definition
  })
end