Class: Capistrano::ASG::Rolling::LaunchTemplates

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/capistrano/asg/rolling/launch_templates.rb

Overview

Collection of Launch Templates.

Instance Method Summary collapse

Constructor Details

#initialize(templates = []) ⇒ LaunchTemplates

Returns a new instance of LaunchTemplates.



12
13
14
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 12

def initialize(templates = [])
  @templates = Set.new(templates)
end

Instance Method Details

#<<(template) ⇒ Object



16
17
18
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 16

def <<(template)
  @templates << template
end

#each(&block) ⇒ Object



24
25
26
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 24

def each(&block)
  @templates.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 28

def empty?
  @templates.empty?
end

#merge(templates) ⇒ Object



20
21
22
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 20

def merge(templates)
  @templates.merge(templates)
end

#update(amis:, description: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 32

def update(amis:, description: nil)
  updated_templates = []

  amis.each do |ami|
    old_image_id = ami.instance.image_id
    new_image_id = ami.id

    with_image(old_image_id).each do |template|
      updated_templates << template.create_version(image_id: new_image_id, description: description)
    end
  end

  self.class.new(updated_templates)
end