capistrano-gcp-autoscaling 0.1.0 → 0.1.1

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: ec2ae2059e98aee5d438dbba5b5752ac15af4dbbf34708e18d386462e2b9fbea
4
- data.tar.gz: c5432d74d75e77c3d1124f1f2c8fc71d791d2c89e64413b5202ed8aea9aa3867
3
+ metadata.gz: 6b5c4394b5eb9f38b2fd71ce873b7abb55c0710cf98ccfa23aba145230e22bfd
4
+ data.tar.gz: 5f320b6e0d46b9cf6aa8c4427140fea14e95885207471004120acb0e6466bf08
5
5
  SHA512:
6
- metadata.gz: 73c358b3b10b3ebfd84f6390c6a35554f2aa1d5d73d6bc7bb6cd4f58b8e1d1bd2814938f05ad1545c39dc02b80f7765520910898be68c9e73a44ae3fabb77e9d
7
- data.tar.gz: 73c64322f6dafed4248b32b8ef3e4a46a9ca2ef6676d0192e5bd9ea144befeb1635dc3fabb1317e9530517e44686672226f3c5a0b1b1d200ad755774709e49c0
6
+ metadata.gz: c44a4eadbc38484136344fe4dc43e010105ad4a217736669a964cac482364ebe98f18adbcc24a8622c07a61146eba49d5c446f143124ec5cb2a565d8c1cdef12
7
+ data.tar.gz: '048cdfcd4192037e755697c81e215134c9a7bb42c04df1a6251617d3ea8b2f931497258eea62c549b0425fec05accc8273b256c2db6f2bc1a6431413af262cab'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-gcp-autoscaling (0.1.0)
4
+ capistrano-gcp-autoscaling (0.1.1)
5
5
  capistrano (~> 3.0)
6
6
  google-api-client (~> 0.8)
7
7
  googleauth (>= 0.6)
data/README.md CHANGED
@@ -33,7 +33,6 @@ 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_filter, '(status eq "RUNNING")'
37
36
  set :gcp_scope, 'https://www.googleapis.com/auth/compute'
38
37
  set :gcp_private_key, ENV['GCP_PRIVATE_KEY']
39
38
  set :gcp_client_email, ENV['GCP_CLIENT_EMAIL']
@@ -22,7 +22,6 @@ def instance_group_manager(group_manager_name, properties = {})
22
22
  compute_service,
23
23
  gcp_project_id: fetch(:gcp_project_id),
24
24
  gcp_region: fetch(:gcp_region),
25
- gcp_filter: fetch(:gcp_filter),
26
25
  group_manager_name: group_manager_name
27
26
  )
28
27
 
@@ -8,6 +8,7 @@ module Capistrano
8
8
  INSTANCE_PATTERN = %r{/instances/[\w-]+}.freeze
9
9
  ZONE_PATTERN = %r{/zones/[\w-]+}.freeze
10
10
  SEPARATOR = '/'.freeze
11
+ RUNNING_STATUS = 'RUNNING'.freeze
11
12
 
12
13
  def initialize(compute_service, managed_instance, options = {})
13
14
  @compute_service = compute_service
@@ -19,12 +20,20 @@ module Capistrano
19
20
  instance.network_interfaces.first.network_ip
20
21
  end
21
22
 
23
+ def created_at
24
+ Time.parse(instance.creation_timestamp)
25
+ end
26
+
27
+ def running?
28
+ instance.status == RUNNING_STATUS
29
+ end
30
+
22
31
  private
23
32
 
24
33
  attr_reader :compute_service, :managed_instance, :options
25
34
 
26
35
  def instance
27
- compute_service.get_instance(options.fetch(:gcp_project_id), instance_zone, instance_name)
36
+ @instance ||= compute_service.get_instance(options.fetch(:gcp_project_id), instance_zone, instance_name)
28
37
  end
29
38
 
30
39
  def instance_zone
@@ -11,7 +11,7 @@ module Capistrano
11
11
  end
12
12
 
13
13
  def instances
14
- group_manager.managed_instances.map(&method(:instance_for))
14
+ group_manager.managed_instances.map(&method(:instance_for)).select(&:running?).sort_by(&:created_at)
15
15
  end
16
16
 
17
17
  private
@@ -30,8 +30,7 @@ module Capistrano
30
30
  compute_service.list_region_instance_group_manager_managed_instances(
31
31
  options.fetch(:gcp_project_id),
32
32
  options.fetch(:gcp_region),
33
- options.fetch(:group_manager_name),
34
- filter: options.fetch(:gcp_filter)
33
+ options.fetch(:group_manager_name)
35
34
  )
36
35
  end
37
36
  end
@@ -3,7 +3,7 @@
3
3
  module Capistrano
4
4
  module Gcp
5
5
  module Autoscaling
6
- VERSION = '0.1.0'.freeze
6
+ VERSION = '0.1.1'.freeze
7
7
  end
8
8
  end
9
9
  end
@@ -4,7 +4,6 @@ namespace :load do
4
4
  task :defaults do
5
5
  set :gcp_project_id, nil
6
6
  set :gcp_region, nil
7
- set :gcp_filter, '(status eq "RUNNING")'
8
7
  set :gcp_scope, 'https://www.googleapis.com/auth/compute'
9
8
  set :gcp_private_key, ENV['GCP_PRIVATE_KEY']
10
9
  set :gcp_client_email, ENV['GCP_CLIENT_EMAIL']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-gcp-autoscaling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Vorobyov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-26 00:00:00.000000000 Z
11
+ date: 2019-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler