kumo_keisei 0.0.54 → 1.0.0.pre

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: aafae086e285b92c93f77d21ab4938c4dc4458dd
4
- data.tar.gz: de6b75f61452599be6dcbd375e0bef150ed7a07f
3
+ metadata.gz: 177b3f9fa23f963bfa4d4448f362a242449ad975
4
+ data.tar.gz: 9c48934d039457ff2f5ba4c3843d5e620cee9070
5
5
  SHA512:
6
- metadata.gz: 930367bd74af5b2ab2e423f41d123dd904fe33bf21c1035846ae9f0bd327b8eecaf517a2029ef0c9d81e07d5c5a887061f0c07cbe9fb7d365018744f1689fe7c
7
- data.tar.gz: 665b7bab8e79ac469c3cfcf3da8c9697fd2866bbe9034a11409d538a4901f335684e3df8db684ad25a4a91c88c70396db41a2b1fcfc379df4843eaa46306f4d0
6
+ metadata.gz: f0fc8ee74a5ce6406fd5f40f153bd3531bcca54a30661e97dcc6912a61ea64b52f154e111932c3627764ade49573a2175a39598d4c782e1d9a60a3d3ccab676a
7
+ data.tar.gz: 43c8ac7e1290695186629b08ecc0a657578bf2c3b5a22889355be85ee27b0bb591894cc73e91724832453d49573b9d951ddb15876384ca2dbb9f10289a87e349
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.54
1
+ 1.0.0.pre
@@ -11,11 +11,11 @@ module KumoKeisei
11
11
  UPDATEABLE_STATUSES = [
12
12
  'UPDATE_ROLLBACK_COMPLETE',
13
13
  'CREATE_COMPLETE',
14
- 'UPDATE_COMPLETE',
15
- 'DELETE_COMPLETE'
14
+ 'UPDATE_COMPLETE'
16
15
  ]
17
16
 
18
17
  RECOVERABLE_STATUSES = [
18
+ 'DELETE_COMPLETE',
19
19
  'ROLLBACK_COMPLETE',
20
20
  'ROLLBACK_FAILED'
21
21
  ]
@@ -42,7 +42,6 @@ module KumoKeisei
42
42
  if updatable?
43
43
  update!(dynamic_params)
44
44
  else
45
- ConsoleJockey.write_line "There's a previous stack called #{@stack_name} that didn't create properly, I'll clean it up for you..."
46
45
  ensure_deleted!
47
46
  ConsoleJockey.write_line "Creating your new stack #{@stack_name}"
48
47
  create!(dynamic_params)
@@ -50,6 +49,8 @@ module KumoKeisei
50
49
  end
51
50
 
52
51
  def destroy!
52
+ return if get_stack.nil?
53
+
53
54
  wait_until_ready(false)
54
55
  ensure_deleted!
55
56
  end
@@ -80,6 +81,8 @@ module KumoKeisei
80
81
  @stack = nil if options[:dump_cache]
81
82
 
82
83
  @stack ||= cloudformation.describe_stacks(stack_name: @stack_name).stacks.find { |stack| stack.stack_name == @stack_name }
84
+ rescue Aws::CloudFormation::Errors::ValidationError
85
+ nil
83
86
  end
84
87
 
85
88
  def cloudformation
@@ -87,19 +90,23 @@ module KumoKeisei
87
90
  end
88
91
 
89
92
  def ensure_deleted!
93
+ stack = get_stack
94
+ return if stack.nil?
95
+ return if stack.stack_status == 'DELETE_COMPLETE'
96
+
97
+ ConsoleJockey.write_line "There's a previous stack called #{@stack_name} that didn't create properly, I'll clean it up for you..."
90
98
  cloudformation.delete_stack(stack_name: @stack_name)
91
99
  cloudformation.wait_until(:stack_delete_complete, stack_name: @stack_name) { |waiter| waiter.delay = 20; waiter.max_attempts = 45 }
92
100
  end
93
101
 
94
102
  def updatable?
95
103
  stack = get_stack
104
+ return false if stack.nil?
96
105
 
97
106
  return true if UPDATEABLE_STATUSES.include? stack.stack_status
98
107
  return false if RECOVERABLE_STATUSES.include? stack.stack_status
99
108
  raise UpdateError.new("Stack is in an unrecoverable state") if UNRECOVERABLE_STATUSES.include? stack.stack_status
100
109
  raise UpdateError.new("Stack is busy, try again soon")
101
- rescue Aws::CloudFormation::Errors::ValidationError
102
- false
103
110
  end
104
111
 
105
112
  def create!(dynamic_params)
@@ -52,7 +52,7 @@ describe KumoKeisei::CloudFormationStack do
52
52
 
53
53
  describe "#apply!" do
54
54
  context "when the stack is updatable" do
55
- UPDATEABLE_STATUSES = ['UPDATE_ROLLBACK_COMPLETE', 'CREATE_COMPLETE', 'UPDATE_COMPLETE', 'DELETE_COMPLETE']
55
+ UPDATEABLE_STATUSES = ['UPDATE_ROLLBACK_COMPLETE', 'CREATE_COMPLETE', 'UPDATE_COMPLETE']
56
56
 
57
57
  context "when the stack has changed" do
58
58
  before do
@@ -107,6 +107,16 @@ describe KumoKeisei::CloudFormationStack do
107
107
  allow(cloudformation).to receive(:delete_stack).with(stack_name: stack_name)
108
108
  end
109
109
 
110
+ context "and the stack has status DELETE_COMPLETE" do
111
+
112
+ it "creates the stack and does not attempt to delete the stack" do
113
+ expect(cloudformation).not_to receive(:delete_stack)
114
+ allow(cloudformation).to receive(:describe_stacks).with(stack_name: stack_name).and_return(stack_result_list_with_status('DELETE_COMPLETE', stack_name))
115
+ expect(cloudformation).to receive(:create_stack).with(cf_stack_create_params)
116
+ subject.apply!
117
+ end
118
+ end
119
+
110
120
  context "and the stack does not exist" do
111
121
  let(:stack_name) { "my-stack" }
112
122
 
@@ -118,8 +128,16 @@ describe KumoKeisei::CloudFormationStack do
118
128
  end
119
129
 
120
130
  it "shows a friendly error message if the stack had issues during creation" do
131
+ @call_count = 0
132
+
121
133
  allow(cloudformation).to receive(:delete_stack)
122
- allow(cloudformation).to receive(:describe_stacks).with(stack_name: stack_name).and_raise(Aws::CloudFormation::Errors::ValidationError.new('',''))
134
+ allow(cloudformation).to receive(:describe_stacks).with(stack_name: stack_name) do
135
+ @call_count += 1
136
+
137
+ raise Aws::CloudFormation::Errors::ValidationError.new('','') if @call_count > 1
138
+
139
+ OpenStruct.new(stacks: [])
140
+ end
123
141
  allow(cloudformation).to receive(:create_stack).with(cf_stack_create_params)
124
142
 
125
143
  error = Aws::Waiters::Errors::UnexpectedError.new(RuntimeError.new("Stack with id #{stack_name} does not exist"))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumo_keisei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.54
4
+ version: 1.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redbubble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -124,9 +124,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - ">"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: 1.3.1
130
130
  requirements: []
131
131
  rubyforge_project:
132
132
  rubygems_version: 2.2.2