capistrano-aws-ec2 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43f13493bf402276353eeb52a2506043115adc63e80d91454d785a17256e0d6b
4
- data.tar.gz: 1b8e0990c80bc0c7de9a6faed7738af1a8fafc4ffbd394b0f3d3245411240b93
3
+ metadata.gz: f81df23d8d0fd91ec0118914d065f86cc3c9306989cb5ba73bea10722f99bc01
4
+ data.tar.gz: 4b46e7443eb7ece57a5dd7a74c763c6cb0221f90477fe99e082cefcfc3bcfcb7
5
5
  SHA512:
6
- metadata.gz: c67af9faf94e7ec215d7629a7691970a51c53d41c702dccd85fffd2dfb02d6434d2a5ea9c93ea36486b10a5c4a4e7b95b39e7fbf0a1b98f66a1739985f389a24
7
- data.tar.gz: 203f7c59dd8fbc07a5a2ec9c085ed682116f4d744d917608cefb3da93e670bfc7415bf0f9eaed7894eb4094565a473091aae79a8a903479b26935f7f78e7dd86
6
+ metadata.gz: 83a2ed3c4e74cd96b1fd940977b0d987cfa5ea358ce5a4139d10b828632b5a419aa0883f0ad0615ed4ae5655d92c3571b1e57d06cc9d884ae78a46d5f78b5c3d
7
+ data.tar.gz: c546012741625dcbdb7bf0959f0593c5dee08ee0adc5d2f3dc58e08d824f681650f1fdaa4c2090ae82af14bac2267e4ac5d78c669a69014ff964510a479805f9
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ #### 0.1.7 ####
5
+ * Filter out non-running instances by default
6
+
4
7
  #### 0.1 ####
5
8
  * Add `ec2_instances` finder
6
9
  * Add optional tag filter
data/README.md CHANGED
@@ -53,7 +53,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
53
53
 
54
54
  ## Contributing
55
55
 
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/capistrano-aws-ec2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/zyndoras/capistrano-aws-ec2/blob/master/CODE_OF_CONDUCT.md).
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zyndoras/capistrano-aws-ec2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/zyndoras/capistrano-aws-ec2/blob/master/CODE_OF_CONDUCT.md).
57
57
 
58
58
  ## License
59
59
 
@@ -61,4 +61,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
61
61
 
62
62
  ## Code of Conduct
63
63
 
64
- Everyone interacting in the Capistrano::Aws::Ec2 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/capistrano-aws-ec2/blob/master/CODE_OF_CONDUCT.md).
64
+ Everyone interacting in the Capistrano::Aws::Ec2 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/zyndoras/capistrano-aws-ec2/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require_relative 'lib/capistrano/aws/ec2/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'capistrano-aws-ec2'
9
+ spec.version = Capistrano::Aws::Ec2::VERSION
10
+ spec.authors = ['Alex Sella']
11
+ spec.email = ['zyndoras@gmail.com']
12
+
13
+ spec.summary = 'Deploy to AWS EC2 via Capistrano.'
14
+ spec.description = 'Dynamically select EC2 instances to interact with using Capistrano.'
15
+ spec.homepage = 'https://github.com/zyndoras/capistrano-aws-ec2'
16
+ spec.license = 'MIT'
17
+ spec.required_ruby_version = '>= 2.6.0'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/zyndoras/capistrano-aws-ec2'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/zyndoras/capistrano-aws-ec2/blob/master/CHANGELOG.md'
22
+
23
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
30
+ end
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.add_dependency 'aws-sdk-ec2', '~> 1.0'
37
+ spec.add_dependency 'capistrano', '~> 3.0'
38
+
39
+ spec.add_development_dependency 'rake', '~> 13.0'
40
+ spec.add_development_dependency 'rspec', '~> 3.0'
41
+ spec.add_development_dependency 'rubocop'
42
+ spec.add_development_dependency 'rubocop-performance'
43
+ end
@@ -3,13 +3,18 @@
3
3
  require 'aws-sdk-ec2'
4
4
 
5
5
  module Capistrano
6
+ # Patches the Capistrano Configuration class to add our aws-ec2 features
6
7
  class Configuration
8
+ EC2_STATE_RUNNING_CODE = 16
7
9
 
8
- def ec2_instances(tags: nil)
9
- instances = ec2_resource.instances
10
- return instances if tags.nil?
10
+ def ec2_instances(running_only: true, tags: {})
11
+ ec2_resource.instances.filter do |instance|
12
+ # Filter out non-running instances
13
+ next false if running_only && instance.state.code != EC2_STATE_RUNNING_CODE
11
14
 
12
- instances.filter { |i| tags.all? { |k, v| i.tags.any? { |tag| tag.key == k && tag.value == v } } }
15
+ # Filter out instances not matching the given tags
16
+ tags.all? { |k, v| i.tags.any? { |tag| tag.key == k && tag.value == v } }
17
+ end
13
18
  end
14
19
 
15
20
  private
@@ -3,7 +3,7 @@
3
3
  module Capistrano
4
4
  module Aws
5
5
  module Ec2
6
- VERSION = '0.1.6'
6
+ VERSION = '0.1.7'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-aws-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Sella
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-14 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ec2
@@ -109,6 +109,7 @@ files:
109
109
  - LICENSE.txt
110
110
  - README.md
111
111
  - Rakefile
112
+ - capistrano-aws-ec2.gemspec
112
113
  - lib/capistrano/aws/ec2.rb
113
114
  - lib/capistrano/aws/ec2/patches.rb
114
115
  - lib/capistrano/aws/ec2/version.rb
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  - !ruby/object:Gem::Version
136
137
  version: '0'
137
138
  requirements: []
138
- rubygems_version: 3.2.32
139
+ rubygems_version: 3.2.28
139
140
  signing_key:
140
141
  specification_version: 4
141
142
  summary: Deploy to AWS EC2 via Capistrano.