Skip to content

Commit

Permalink
Allow adding custom tags to an AMI.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppostma committed Nov 5, 2024
1 parent 7b96328 commit 269366d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/capistrano/asg/rolling/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Tags

# The tags to add to an AMI.
def ami_tags
application_tags.merge(deployment_tags).merge(gem_tags)
application_tags.merge(deployment_tags).merge(gem_tags).merge(custom_tags)
end

# Tags related to the current application / stage.
Expand All @@ -36,6 +36,11 @@ def gem_tags
'capistrano-asg-rolling:gem-version' => Capistrano::ASG::Rolling::VERSION
}
end

# Custom added tags.
def custom_tags
fetch(:asg_rolling_ami_tags) || {}
end
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/capistrano/asg/rolling/tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@
)
end
end

describe '#custom_tags' do
before { Capistrano::ASG::Rolling::Configuration.set(:asg_rolling_ami_tags, { 'custom-tag' => 'foobar' }) }

it 'returns a hash with custom tags' do
expect(described_class.custom_tags).to eq(
'custom-tag' => 'foobar'
)
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Capistrano::ASG::Rolling::Configuration.instance_variable_set(:@instances, nil)
Capistrano::ASG::Rolling::Configuration.instance_variable_set(:@launch_templates, nil)

Capistrano::ASG::Rolling::Configuration.set(:asg_rolling_ami_tags, nil)
Capistrano::ASG::Rolling::Configuration.set(:asg_rolling_group_name, nil)
Capistrano::ASG::Rolling::Configuration.set(:asg_rolling_use_private_ip_address, true)

Expand Down

0 comments on commit 269366d

Please sign in to comment.