ecs_deployer 0.1.12 → 0.1.13

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
  SHA1:
3
- metadata.gz: e60347cf25748e10ebd8fb31c60a16bcb7c744f0
4
- data.tar.gz: 70df50d8c38bafe0637bc36baf59dff095faeb92
3
+ metadata.gz: 8dbede2e477b7494c7ce86d997b1bc63760be467
4
+ data.tar.gz: 09ab13c573ae1fc4efb73daef2be2e85fb356fe7
5
5
  SHA512:
6
- metadata.gz: 96b2e854dc1c9dbf9a789ceba7e24fc97913fdaed3fdc54f85616e7fe159acaa44e63a9a3211a2961d911e744b7189683f29912fc9a36e859463f50da3aa6d77
7
- data.tar.gz: 927248da5b5c2aaee7f92012455155fb6f3a8380ce28ae05b4afac6dc88e81d858b5b336e55296813f4f75bebf80893500c44eb827f24a1fa278bcfd26c73ebe
6
+ metadata.gz: d1ae2cc0e11b1ee2909a771d240bb27b8e3b31ac49beeb8860738709df4b319a600413910c6bd87acdf81c88e6249db5c771cc217238ef6b26727be80e446383
7
+ data.tar.gz: 6c2fb378ca31391072450169588915f8ad5fe10c936db13a633b936c9395d763940412abe15ae7a88a120c2501baed234bb4d3a7cea0e01b351d2bb3553375e5
data/.rubocop.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - 'tmp/**/*'
3
+ - 'tmp/**/*'
4
+ Style/BlockComments:
5
+ Enabled: false
4
6
  Style/Documentation:
5
7
  Enabled: false
6
8
  Style/ExtraSpacing:
@@ -8,7 +10,7 @@ Style/ExtraSpacing:
8
10
  Style/FrozenStringLiteralComment:
9
11
  Enabled: false
10
12
  Metrics/AbcSize:
11
- Max: 20
13
+ Max: 64
12
14
  Metrics/BlockLength:
13
15
  Enabled: false
14
16
  Metrics/ClassLength:
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # EcsDeployer
2
2
 
3
+ [![CircleCI](https://circleci.com/gh/naomichi-y/ecs_deployer/tree/master.svg?style=svg)](https://circleci.com/gh/naomichi-y/ecs_deployer/tree/master)
4
+ [![Gem Version](https://badge.fury.io/rb/ecs_deployer.svg)](https://badge.fury.io/rb/ecs_deployer)
5
+
6
+ ## Description
7
+
3
8
  This package provides service deployment function of ECS.
4
9
 
5
10
  ## Installation
@@ -12,11 +17,15 @@ gem 'ecs_deployer'
12
17
 
13
18
  And then execute:
14
19
 
15
- $ bundle
20
+ ```
21
+ $ bundle
22
+ ```
16
23
 
17
24
  Or install it yourself as:
18
25
 
19
- $ gem install ecs_deployer
26
+ ```
27
+ $ gem install ecs_deployer
28
+ ```
20
29
 
21
30
  ## Task definition
22
31
 
@@ -5,14 +5,19 @@ module EcsDeployer
5
5
  class_option :profile, type: :string
6
6
  class_option :region, type: :string
7
7
 
8
- def initialize(*args)
9
- super
10
-
11
- aws_options = {}
12
- aws_options[:profile] = options[:profile] if options[:profile]
13
- aws_options[:region] = options[:region] if options[:region]
14
-
15
- @deployer = EcsDeployer::Client.new(aws_options)
8
+ no_commands do
9
+ def prepare
10
+ aws_options = {}
11
+ aws_options[:profile] = options[:profile] if options[:profile]
12
+ aws_options[:region] = options[:region] if options[:region]
13
+
14
+ @deployer = EcsDeployer::Client.new(aws_options)
15
+ end
16
+
17
+ def invoke_command(command, *args)
18
+ prepare
19
+ super
20
+ end
16
21
  end
17
22
 
18
23
  desc 'task_register', 'Create new task definition'
@@ -28,13 +33,13 @@ module EcsDeployer
28
33
  option :cluster, required: true
29
34
  option :service, required: true
30
35
  option :wait, type: :boolean, default: true
31
- option :timeout, type: :numeric, default: EcsDeployer::Client::DEPLOY_TIMEOUT
36
+ option :timeout, type: :numeric, default: 600
32
37
  def update_service
38
+ @deployer.timeout = options[:timeout]
33
39
  result = @deployer.update_service(
34
40
  options[:cluster],
35
41
  options[:service],
36
- options[:wait],
37
- options[:timeout]
42
+ options[:wait]
38
43
  )
39
44
 
40
45
  puts "Update service: #{result}"
@@ -7,11 +7,10 @@ require 'base64'
7
7
  module EcsDeployer
8
8
  class Client
9
9
  LOG_SEPARATOR = '-' * 96
10
- PAULING_INTERVAL = 20
11
- DEPLOY_TIMEOUT = 600
12
10
  ENCRYPT_PATTERN = /^\${(.+)}$/
13
11
 
14
12
  attr_reader :cli
13
+ attr_accessor :timeout, :pauling_interval
15
14
 
16
15
  # @param [Hash] aws_options
17
16
  # @option aws_options [String] :profile
@@ -21,6 +20,8 @@ module EcsDeployer
21
20
  @command = RuntimeCommand::Builder.new
22
21
  @cli = Aws::ECS::Client.new(aws_options)
23
22
  @kms = Aws::KMS::Client.new(aws_options)
23
+ @timeout = 600
24
+ @pauling_interval = 20
24
25
  end
25
26
 
26
27
  # @param [String] mater_key
@@ -100,9 +101,8 @@ module EcsDeployer
100
101
 
101
102
  # @param [String] cluster
102
103
  # @param [String] service
103
- # @param [Fixnum] timeout
104
104
  # @return [String]
105
- def update_service(cluster, service, wait = true, timeout = DEPLOY_TIMEOUT)
105
+ def update_service(cluster, service, wait = true)
106
106
  register_clone_task(cluster, service) if @new_task_definition_arn.nil?
107
107
 
108
108
  result = @cli.update_service(
@@ -110,7 +110,7 @@ module EcsDeployer
110
110
  service: service,
111
111
  task_definition: @family + ':' + @revision.to_s
112
112
  )
113
- wait_for_deploy(cluster, service, timeout) if wait
113
+ wait_for_deploy(cluster, service) if wait
114
114
  result.service.service_arn
115
115
  end
116
116
 
@@ -184,8 +184,7 @@ module EcsDeployer
184
184
 
185
185
  # @param [String] cluster
186
186
  # @param [String] service
187
- # @param [Fixnum] timeout
188
- def wait_for_deploy(cluster, service, timeout)
187
+ def wait_for_deploy(cluster, service)
189
188
  service_status = service_status(cluster, service)
190
189
  raise TaskDesiredError, 'Task desired by service is 0.' if service_status[:desired_count].zero?
191
190
 
@@ -193,8 +192,8 @@ module EcsDeployer
193
192
  @command.puts 'Start deploing...'
194
193
 
195
194
  loop do
196
- sleep(PAULING_INTERVAL)
197
- wait_time += PAULING_INTERVAL
195
+ sleep(@pauling_interval)
196
+ wait_time += @pauling_interval
198
197
  result = deploy_status(cluster, service)
199
198
 
200
199
  if result[:new_running_count] == result[:current_running_count]
@@ -211,7 +210,7 @@ module EcsDeployer
211
210
  @command.puts LOG_SEPARATOR
212
211
  @command.puts 'You can stop process with Ctrl+C. Deployment will continue.'
213
212
 
214
- if wait_time > timeout
213
+ if wait_time > @timeout
215
214
  @command.puts "New task definition: #{@new_task_definition_arn}"
216
215
  raise DeployTimeoutError, 'Service is being updating, but process is timed out.'
217
216
  end
@@ -1,3 +1,3 @@
1
1
  module EcsDeployer
2
- VERSION = '0.1.12'.freeze
2
+ VERSION = '0.1.13'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - naomichi-y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: runtime_command