kumogata 0.3.4 → 0.3.5

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
  SHA1:
3
- metadata.gz: d8397ce5ba88d4176308efe41d403a0ff42df2dd
4
- data.tar.gz: c1250a2e9c5e40620136ae46ce09bdaa2058578d
3
+ metadata.gz: 58914196d1e874c6e7d2634c98acc1ab3e0fb6f3
4
+ data.tar.gz: 386325c6bcbe4915ad1020f1a38ba4073087d28a
5
5
  SHA512:
6
- metadata.gz: e7746ac2ff2e1fa7e1b69d436e89550e84e22efb3ee62aaf875e4b29f730b7abcef5b6d5fb97af3872d3556db383d5ce5fea46aabad94fab362a92920e58971b
7
- data.tar.gz: c413ed695774054393d168f62cd53a4f6cfdd3ac1a6115ee2a979b8089e98af74c8f6227cfbfde386413a2c2e0523493e2eb3bbfa0eeaf2e0c7f0c4b422edcdc
6
+ metadata.gz: e5ae37b29e89a0122e3a352cb082a6635102eaccf890a82d07dd68aef2e69988ceda1d942ee117bb9904feb7e23b22b37f4f26c4f05c853bf3058a7e15fdb666
7
+ data.tar.gz: e4fc3e29b20fbc2808cfed21be5d0dd0b6107e1d16fc3d3b890f6c8d46c1d38359b8e545e89b8efc77da2d431090b73c3467c85e6bfdd114b3d229cc490be0c8
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
7
7
 
8
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403091746)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403091746)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403091822)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403091822)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
@@ -280,6 +280,8 @@ end # Resources
280
280
  * https://asciinema.org/a/7979
281
281
  * Convert a template
282
282
  * https://asciinema.org/a/7980
283
+ * Create a stack while outputting the event log
284
+ * https://asciinema.org/a/8075
283
285
 
284
286
  ## Contributing
285
287
 
@@ -220,8 +220,9 @@ class Kumogata::Client
220
220
 
221
221
  Kumogata.logger.info("Creating stack: #{stack_name}".cyan)
222
222
  stack = @cloud_formation.stacks.create(stack_name, template.to_json, build_create_options)
223
+ event_log = {}
223
224
 
224
- unless while_in_progress(stack, 'CREATE_COMPLETE')
225
+ unless while_in_progress(stack, 'CREATE_COMPLETE', event_log)
225
226
  errmsgs = ['Create failed']
226
227
  errmsgs << stack_name
227
228
  errmsgs << stack.status_reason if stack.status_reason
@@ -241,11 +242,12 @@ class Kumogata::Client
241
242
  def update_stack(template, stack_name)
242
243
  stack = @cloud_formation.stacks[stack_name]
243
244
  stack.status
244
- stack.update(build_update_options(template.to_json))
245
245
 
246
246
  Kumogata.logger.info("Updating stack: #{stack_name}".green)
247
+ event_log = create_event_log(stack)
248
+ stack.update(build_update_options(template.to_json))
247
249
 
248
- unless while_in_progress(stack, 'UPDATE_COMPLETE')
250
+ unless while_in_progress(stack, 'UPDATE_COMPLETE', event_log)
249
251
  errmsgs = ['Update failed']
250
252
  errmsgs << stack_name
251
253
  errmsgs << stack.status_reason if stack.status_reason
@@ -262,12 +264,13 @@ class Kumogata::Client
262
264
  stack.status
263
265
 
264
266
  Kumogata.logger.info("Deleting stack: #{stack_name}".red)
267
+ event_log = create_event_log(stack)
265
268
  stack.delete
266
269
 
267
270
  completed = false
268
271
 
269
272
  begin
270
- completed = while_in_progress(stack, 'DELETE_COMPLETE')
273
+ completed = while_in_progress(stack, 'DELETE_COMPLETE', event_log)
271
274
  rescue AWS::CloudFormation::Errors::ValidationError
272
275
  # Handle `Stack does not exist`
273
276
  completed = true
@@ -328,9 +331,7 @@ class Kumogata::Client
328
331
  end
329
332
  end
330
333
 
331
- def while_in_progress(stack, complete_status)
332
- event_log = {}
333
-
334
+ def while_in_progress(stack, complete_status, event_log)
334
335
  while stack.status =~ /_IN_PROGRESS\Z/
335
336
  print_event_log(stack, event_log)
336
337
  sleep 1
@@ -364,6 +365,17 @@ class Kumogata::Client
364
365
  end
365
366
  end
366
367
 
368
+ def create_event_log(stack)
369
+ event_log = {}
370
+
371
+ events_for(stack).sort_by {|i| i['Timestamp'] }.each do |event|
372
+ event_id = event['EventId']
373
+ event_log[event_id] = event
374
+ end
375
+
376
+ return event_log
377
+ end
378
+
367
379
  def build_create_options
368
380
  opts = {}
369
381
  add_parameters(opts)
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  end
@@ -23,6 +23,7 @@ end
23
23
  run_client(:create, :template => template) do |client, cf|
24
24
  json = eval_template(template, :update_deletion_policy => true).to_json
25
25
  client.should_receive(:print_event_log).twice
26
+ client.should_receive(:create_event_log).once
26
27
 
27
28
  output = make_double('output') do |obj|
28
29
  obj.should_receive(:key) { 'AZ' }
@@ -85,6 +86,7 @@ end
85
86
  expect(template['Resources']['myEC2Instance']['DeletionPolicy']).to eq('Delete')
86
87
  json = template.to_json
87
88
  client.should_receive(:print_event_log).twice
89
+ client.should_receive(:create_event_log).once
88
90
 
89
91
  output = make_double('output') do |obj|
90
92
  obj.should_receive(:key) { 'AZ' }
@@ -152,6 +154,7 @@ end
152
154
  run_client(:create, :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}}) do |client, cf|
153
155
  json = eval_template(template, :update_deletion_policy => true).to_json
154
156
  client.should_receive(:print_event_log).twice
157
+ client.should_receive(:create_event_log).once
155
158
 
156
159
  output = make_double('output') do |obj|
157
160
  obj.should_receive(:key) { 'AZ' }
@@ -357,6 +360,7 @@ end
357
360
  run_client(:create, :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => ['Password']}) do |client, cf|
358
361
  json = eval_template(template, :update_deletion_policy => true, :add_encryption_password => true).to_json
359
362
  client.should_receive(:print_event_log).twice
363
+ client.should_receive(:create_event_log).once
360
364
 
361
365
  output = make_double('output') do |obj|
362
366
  obj.should_receive(:key) { 'AZ' }
@@ -2,6 +2,7 @@ describe 'Kumogata::Client#delete' do
2
2
  it 'update a stack from Ruby template' do
3
3
  run_client(:delete, :arguments => ['MyStack'], :options => {:force => true}) do |client, cf|
4
4
  client.should_receive(:print_event_log).once
5
+ client.should_receive(:create_event_log).once
5
6
 
6
7
  stack = make_double('stack') do |obj|
7
8
  obj.should_receive(:delete).with(no_args())
@@ -23,6 +23,7 @@ end
23
23
  run_client(:update, :arguments => ['MyStack'], :template => template) do |client, cf|
24
24
  json = eval_template(template).to_json
25
25
  client.should_receive(:print_event_log).once
26
+ client.should_receive(:create_event_log).once
26
27
 
27
28
  output = make_double('output') do |obj|
28
29
  obj.should_receive(:key) { 'AZ' }
@@ -87,6 +88,7 @@ end
87
88
  run_client(:update, :arguments => ['MyStack'], :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}}) do |client, cf|
88
89
  json = eval_template(template).to_json
89
90
  client.should_receive(:print_event_log).once
91
+ client.should_receive(:create_event_log).once
90
92
 
91
93
  output = make_double('output') do |obj|
92
94
  obj.should_receive(:key) { 'AZ' }
@@ -176,6 +178,7 @@ end
176
178
  run_client(:update, :arguments => ['MyStack'], :template => template, :options => {:parameters => {'InstanceType'=>'m1.large'}, :encrypt_parameters => ['Password']}) do |client, cf|
177
179
  json = eval_template(template, :add_encryption_password => true).to_json
178
180
  client.should_receive(:print_event_log).once
181
+ client.should_receive(:create_event_log).once
179
182
 
180
183
  output = make_double('output') do |obj|
181
184
  obj.should_receive(:key) { 'AZ' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara