Class: Capistrano::ASG::Rolling::LaunchTemplates
- Inherits:
-
Object
- Object
- Capistrano::ASG::Rolling::LaunchTemplates
- Includes:
- Enumerable
- Defined in:
- lib/capistrano/asg/rolling/launch_templates.rb
Overview
Collection of Launch Templates.
Instance Method Summary collapse
- #<<(template) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(templates = []) ⇒ LaunchTemplates
constructor
A new instance of LaunchTemplates.
- #merge(templates) ⇒ Object
-
#update(amis:, description: nil) ⇒ Object
For each AMI, find templates still pointing at the old image it was built from, then create new template versions referencing the new AMI in parallel.
Constructor Details
#initialize(templates = []) ⇒ LaunchTemplates
Returns a new instance of LaunchTemplates.
10 11 12 |
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 10 def initialize(templates = []) @templates = Set.new(templates) end |
Instance Method Details
#<<(template) ⇒ Object
14 15 16 |
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 14 def <<(template) @templates << template end |
#each ⇒ Object
22 23 24 |
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 22 def each(&) @templates.each(&) end |
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 26 def empty? @templates.empty? end |
#merge(templates) ⇒ Object
18 19 20 |
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 18 def merge(templates) @templates.merge(templates) end |
#update(amis:, description: nil) ⇒ Object
For each AMI, find templates still pointing at the old image it was built from, then create new template versions referencing the new AMI in parallel.
Returns LaunchTemplates containing only the newly created versions.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/capistrano/asg/rolling/launch_templates.rb', line 34 def update(amis:, description: nil) template_image_pairs = amis.flat_map do |ami| old_image_id = ami.instance.image_id new_image_id = ami.id with_image(old_image_id).map { |template| [template, new_image_id] } end updated_templates = Parallel.run(template_image_pairs) do |template, new_image_id| template.create_version(image_id: new_image_id, description: description) end self.class.new(updated_templates) end |