capistrano-gcp-autoscaling 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5b766ad469f8c906f13da23d04beae1336aec3459a4023cfc40e54db12c86ae
4
- data.tar.gz: b1fc5d6f4c8f768dfe6e791f0968eb6654ac09790737e3738180e77a2a5717cb
3
+ metadata.gz: 57d248d5241932baf5c918ed91c93e1d8581f96902c5a504f1c141bb082e4d65
4
+ data.tar.gz: fb20b4f0143561c33ddd219f6013e67add91213cb441f06dcb78bb3537fdea18
5
5
  SHA512:
6
- metadata.gz: 39d7a7fc7769b109957284fe4db36ee3c452411854d6a94ff05ec092ce7968f5128ae31cbb34e6fc9881d0e660164c142f3a84260234f932d88ba1da7dd0302a
7
- data.tar.gz: 236f104dcc7de7c5fed2eac6a39fdb4a43361a5023221b9bab4c539981a66657e634e98e05f366fe85ed0a4ddabcdeec155f5df312ba4e04915c81ff98a1f1ed
6
+ metadata.gz: db9fbdde1ce12f0d18b70adf69534e6fbf8bb7b2af31f2d8c751724f7b32dce5267fd937a02615c322cf3f082b38d7ef93154a93d028bac73763395185749423
7
+ data.tar.gz: '098c3dc99733a06b6903ffdea67f0d4ba299ea27e5dc890b943a51986751b3dd367f7b334644d3738484a4a528e40176b8263d7c1089317a338d42dbe534acec'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-gcp-autoscaling (0.1.3)
4
+ capistrano-gcp-autoscaling (0.2.0)
5
5
  capistrano (~> 3.0)
6
6
  google-api-client (~> 0.8)
7
7
  googleauth (>= 0.6)
@@ -9,64 +9,93 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.6.0)
13
- public_suffix (>= 2.0.2, < 4.0)
14
- airbrussh (1.3.1)
12
+ activesupport (5.2.6)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ addressable (2.7.0)
18
+ public_suffix (>= 2.0.2, < 5.0)
19
+ airbrussh (1.4.0)
15
20
  sshkit (>= 1.6.1, != 1.7.0)
16
21
  ast (2.4.0)
17
- capistrano (3.11.0)
22
+ capistrano (3.16.0)
18
23
  airbrussh (>= 1.0.0)
19
24
  i18n
20
25
  rake (>= 10.0.0)
21
26
  sshkit (>= 1.9.0)
22
- concurrent-ruby (1.1.5)
23
- declarative (0.0.10)
24
- declarative-option (0.1.0)
27
+ concurrent-ruby (1.1.9)
28
+ declarative (0.0.20)
25
29
  diff-lcs (1.3)
26
- faraday (0.15.4)
30
+ faraday (1.4.2)
31
+ faraday-em_http (~> 1.0)
32
+ faraday-em_synchrony (~> 1.0)
33
+ faraday-excon (~> 1.1)
34
+ faraday-net_http (~> 1.0)
35
+ faraday-net_http_persistent (~> 1.1)
27
36
  multipart-post (>= 1.2, < 3)
28
- google-api-client (0.28.7)
37
+ ruby2_keywords (>= 0.0.4)
38
+ faraday-em_http (1.0.0)
39
+ faraday-em_synchrony (1.0.0)
40
+ faraday-excon (1.1.0)
41
+ faraday-net_http (1.0.1)
42
+ faraday-net_http_persistent (1.1.0)
43
+ gems (1.2.0)
44
+ google-api-client (0.53.0)
45
+ google-apis-core (~> 0.1)
46
+ google-apis-generator (~> 0.1)
47
+ google-apis-core (0.2.1)
29
48
  addressable (~> 2.5, >= 2.5.1)
30
- googleauth (>= 0.5, < 0.10.0)
49
+ googleauth (~> 0.14)
31
50
  httpclient (>= 2.8.1, < 3.0)
32
- mime-types (~> 3.0)
51
+ mini_mime (~> 1.0)
33
52
  representable (~> 3.0)
34
53
  retriable (>= 2.0, < 4.0)
35
- signet (~> 0.10)
36
- googleauth (0.8.1)
37
- faraday (~> 0.12)
54
+ rexml
55
+ signet (~> 0.14)
56
+ webrick
57
+ google-apis-discovery_v1 (0.1.0)
58
+ google-apis-core (~> 0.1)
59
+ google-apis-generator (0.1.2)
60
+ activesupport (>= 5.0)
61
+ gems (~> 1.2)
62
+ google-apis-core (~> 0.1)
63
+ google-apis-discovery_v1 (~> 0.0)
64
+ thor (>= 0.20, < 2.a)
65
+ googleauth (0.15.1)
66
+ faraday (>= 0.17.3, < 2.0)
38
67
  jwt (>= 1.4, < 3.0)
39
68
  memoist (~> 0.16)
40
69
  multi_json (~> 1.11)
41
70
  os (>= 0.9, < 2.0)
42
- signet (~> 0.7)
71
+ signet (~> 0.14)
43
72
  httpclient (2.8.3)
44
- i18n (1.6.0)
73
+ i18n (1.8.10)
45
74
  concurrent-ruby (~> 1.0)
46
75
  jaro_winkler (1.5.2)
47
- jwt (2.1.0)
48
- memoist (0.16.0)
49
- mime-types (3.2.2)
50
- mime-types-data (~> 3.2015)
51
- mime-types-data (3.2019.0331)
52
- multi_json (1.13.1)
53
- multipart-post (2.0.0)
54
- net-scp (2.0.0)
55
- net-ssh (>= 2.6.5, < 6.0.0)
56
- net-ssh (5.2.0)
57
- os (1.0.0)
76
+ jwt (2.2.3)
77
+ memoist (0.16.2)
78
+ mini_mime (1.1.0)
79
+ minitest (5.14.4)
80
+ multi_json (1.15.0)
81
+ multipart-post (2.1.1)
82
+ net-scp (3.0.0)
83
+ net-ssh (>= 2.6.5, < 7.0.0)
84
+ net-ssh (6.1.0)
85
+ os (1.1.1)
58
86
  parallel (1.15.0)
59
87
  parser (2.6.2.0)
60
88
  ast (~> 2.4.0)
61
89
  psych (3.1.0)
62
- public_suffix (3.0.3)
90
+ public_suffix (4.0.6)
63
91
  rainbow (3.0.0)
64
- rake (10.5.0)
65
- representable (3.0.4)
92
+ rake (13.0.1)
93
+ representable (3.1.1)
66
94
  declarative (< 0.1.0)
67
- declarative-option (< 0.2.0)
95
+ trailblazer-option (>= 0.1.1, < 0.2.0)
68
96
  uber (< 0.2.0)
69
97
  retriable (3.1.2)
98
+ rexml (3.2.5)
70
99
  rspec (3.8.0)
71
100
  rspec-core (~> 3.8.0)
72
101
  rspec-expectations (~> 3.8.0)
@@ -91,27 +120,34 @@ GEM
91
120
  rubocop-rspec (1.32.0)
92
121
  rubocop (>= 0.60.0)
93
122
  ruby-progressbar (1.10.0)
94
- signet (0.11.0)
123
+ ruby2_keywords (0.0.4)
124
+ signet (0.14.1)
95
125
  addressable (~> 2.3)
96
- faraday (~> 0.9)
126
+ faraday (>= 0.17.3, < 2.0)
97
127
  jwt (>= 1.5, < 3.0)
98
128
  multi_json (~> 1.10)
99
- sshkit (1.18.2)
129
+ sshkit (1.21.2)
100
130
  net-scp (>= 1.1.2)
101
131
  net-ssh (>= 2.8.0)
132
+ thor (1.1.0)
133
+ thread_safe (0.3.6)
134
+ trailblazer-option (0.1.1)
135
+ tzinfo (1.2.9)
136
+ thread_safe (~> 0.1)
102
137
  uber (0.1.0)
103
138
  unicode-display_width (1.5.0)
139
+ webrick (1.7.0)
104
140
 
105
141
  PLATFORMS
106
142
  ruby
107
143
 
108
144
  DEPENDENCIES
109
- bundler (~> 1.16)
145
+ bundler (>= 2.1.4)
110
146
  capistrano-gcp-autoscaling!
111
- rake (~> 10.0)
147
+ rake (~> 13.0)
112
148
  rspec (~> 3.0)
113
149
  rubocop (~> 0.66)
114
150
  rubocop-rspec (~> 1.32)
115
151
 
116
152
  BUNDLED WITH
117
- 1.17.3
153
+ 2.1.4
data/README.md CHANGED
@@ -33,6 +33,7 @@ Read the documentation (https://cloud.google.com/iam/docs/creating-managing-serv
33
33
  ```ruby
34
34
  set :gcp_project_id, nil
35
35
  set :gcp_region, nil
36
+ set :gcp_zone, nil
36
37
  set :gcp_scope, 'https://www.googleapis.com/auth/compute'
37
38
  set :gcp_private_key, ENV['GCP_PRIVATE_KEY']
38
39
  set :gcp_client_email, ENV['GCP_CLIENT_EMAIL']
@@ -48,6 +49,12 @@ instance_group_manager 'my-instance-group-manager1', user: 'apps', roles: %i(app
48
49
  instance_group_manager 'my-instance-group-manager2' do |_instance, index|
49
50
  index.zero? ? { user: 'apps', roles: %i(app web db) } : { user: 'apps', roles: %i(app web) }
50
51
  end
52
+
53
+ instance_group 'my-instance-group1', user: 'apps', roles: %i(app web db)
54
+
55
+ instance_group 'my-instance-group2' do |_instance, index|
56
+ index.zero? ? { user: 'apps', roles: %i(app web db) } : { user: 'apps', roles: %i(app web) }
57
+ end
51
58
  ```
52
59
 
53
60
  ## Development
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'capistrano-gcp-autoscaling'
7
7
  spec.version = Capistrano::Gcp::Autoscaling::VERSION
8
8
  spec.authors = ['Aleksei Vorobyov']
9
- spec.email = ['effypad@gmail.com']
9
+ spec.email = ['a3.vorobyov@gmail.com']
10
10
 
11
11
  spec.summary = 'Capistrano plugin for deploying to GCP instance groups'
12
12
  spec.description = spec.summary
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.16'
25
- spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'bundler', '>= 2.1.4'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
27
  spec.add_development_dependency 'rubocop', '~> 0.66'
28
28
  spec.add_development_dependency 'rubocop-rspec', '~> 1.32'
@@ -4,6 +4,7 @@ require 'googleauth'
4
4
  require 'google/apis/compute_v1'
5
5
  require 'capistrano/gcp/autoscaling/core/compute_service'
6
6
  require 'capistrano/gcp/autoscaling/core/instance'
7
+ require 'capistrano/gcp/autoscaling/core/instance_group'
7
8
  require 'capistrano/gcp/autoscaling/core/instance_group_manager'
8
9
 
9
10
  load File.expand_path('tasks/autoscaling.rake', __dir__)
@@ -29,3 +30,16 @@ def instance_group_manager(group_manager_name, properties = {})
29
30
  server instance.network_ip, block_given? ? yield(instance, index) : properties
30
31
  end
31
32
  end
33
+
34
+ def instance_group(group_name, properties = {})
35
+ instance_group = Capistrano::Gcp::Autoscaling::Core::InstanceGroup.new(
36
+ compute_service,
37
+ gcp_project_id: fetch(:gcp_project_id),
38
+ gcp_zone: fetch(:gcp_zone),
39
+ group_name: group_name
40
+ )
41
+
42
+ instance_group.instances.each_with_index do |instance, index|
43
+ server instance.network_ip, block_given? ? yield(instance, index) : properties
44
+ end
45
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Capistrano
4
+ module Gcp
5
+ module Autoscaling
6
+ module Core
7
+ class InstanceGroup
8
+ def initialize(compute_service, options = {})
9
+ @compute_service = compute_service
10
+ @options = options
11
+ end
12
+
13
+ def instances
14
+ group.items.map(&method(:instance_for)).select(&:available?).sort_by(&:created_at)
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :compute_service, :options
20
+
21
+ def instance_for(managed_instance)
22
+ Capistrano::Gcp::Autoscaling::Core::Instance.new(
23
+ compute_service,
24
+ managed_instance,
25
+ gcp_project_id: options.fetch(:gcp_project_id)
26
+ )
27
+ end
28
+
29
+ def group
30
+ compute_service.list_instance_group_instances(
31
+ options.fetch(:gcp_project_id), options.fetch(:gcp_zone), options.fetch(:group_name)
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -4,29 +4,14 @@ module Capistrano
4
4
  module Gcp
5
5
  module Autoscaling
6
6
  module Core
7
- class InstanceGroupManager
8
- def initialize(compute_service, options = {})
9
- @compute_service = compute_service
10
- @options = options
11
- end
12
-
7
+ class InstanceGroupManager < Capistrano::Gcp::Autoscaling::Core::InstanceGroup
13
8
  def instances
14
- group_manager.managed_instances.map(&method(:instance_for)).select(&:available?).sort_by(&:created_at)
9
+ group.managed_instances.map(&method(:instance_for)).select(&:available?).sort_by(&:created_at)
15
10
  end
16
11
 
17
12
  private
18
13
 
19
- attr_reader :compute_service, :options
20
-
21
- def instance_for(managed_instance)
22
- Capistrano::Gcp::Autoscaling::Core::Instance.new(
23
- compute_service,
24
- managed_instance,
25
- gcp_project_id: options.fetch(:gcp_project_id)
26
- )
27
- end
28
-
29
- def group_manager
14
+ def group
30
15
  compute_service.list_region_instance_group_manager_managed_instances(
31
16
  options.fetch(:gcp_project_id),
32
17
  options.fetch(:gcp_region),
@@ -3,7 +3,7 @@
3
3
  module Capistrano
4
4
  module Gcp
5
5
  module Autoscaling
6
- VERSION = '0.1.3'.freeze
6
+ VERSION = '0.2.0'.freeze
7
7
  end
8
8
  end
9
9
  end
@@ -4,6 +4,7 @@ namespace :load do
4
4
  task :defaults do
5
5
  set :gcp_project_id, nil
6
6
  set :gcp_region, nil
7
+ set :gcp_zone, nil
7
8
  set :gcp_scope, 'https://www.googleapis.com/auth/compute'
8
9
  set :gcp_private_key, ENV['GCP_PRIVATE_KEY']
9
10
  set :gcp_client_email, ENV['GCP_CLIENT_EMAIL']
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-gcp-autoscaling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Vorobyov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-26 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.1.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +124,7 @@ dependencies:
124
124
  version: '0.6'
125
125
  description: Capistrano plugin for deploying to GCP instance groups
126
126
  email:
127
- - effypad@gmail.com
127
+ - a3.vorobyov@gmail.com
128
128
  executables:
129
129
  - console
130
130
  - setup
@@ -145,6 +145,7 @@ files:
145
145
  - lib/capistrano/gcp/autoscaling.rb
146
146
  - lib/capistrano/gcp/autoscaling/core/compute_service.rb
147
147
  - lib/capistrano/gcp/autoscaling/core/instance.rb
148
+ - lib/capistrano/gcp/autoscaling/core/instance_group.rb
148
149
  - lib/capistrano/gcp/autoscaling/core/instance_group_manager.rb
149
150
  - lib/capistrano/gcp/autoscaling/version.rb
150
151
  - lib/capistrano/gcp/tasks/autoscaling.rake
@@ -152,7 +153,7 @@ homepage: https://github.com/a3vorobyov/capistrano-gcp-autoscaling
152
153
  licenses:
153
154
  - MIT
154
155
  metadata: {}
155
- post_install_message:
156
+ post_install_message:
156
157
  rdoc_options: []
157
158
  require_paths:
158
159
  - lib
@@ -167,9 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: '0'
169
170
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.7.9
172
- signing_key:
171
+ rubygems_version: 3.0.8
172
+ signing_key:
173
173
  specification_version: 4
174
174
  summary: Capistrano plugin for deploying to GCP instance groups
175
175
  test_files: []