simple_deploy 0.7.5 → 0.7.6.beta.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ coverage
6
6
  .ruby-version
7
7
  .rvmrc
8
8
  *.swp
9
+ .idea/*
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## HEAD:
2
+
3
+ * Fixed issue 176 where multiple deploys did not exit if first deploy failed
4
+ * Fixed find_xml_file error when a blank exception is thrown from cloudformation.
5
+
1
6
  ## v0.7.5 (07/02/13):
2
7
 
3
8
  * Fixed bug with forced deployment in 0.7.4
@@ -11,21 +11,33 @@ module SimpleDeploy
11
11
  end
12
12
 
13
13
  def process
14
- message = XmlSimple.xml_in @exception.response.body
15
- message['Error'].first['Message'].each do |msg|
16
- case msg
17
- when 'No updates are to be performed.'
18
- @logger.info msg
19
- when /^Stack:(.*) does not exist$/
20
- @logger.error msg
21
- raise Exceptions::UnknownStack.new msg
14
+ @logger.debug "Object type = #{@exception.class}"
15
+ if @exception.respond_to?(:response)
16
+ unless @exception.response.body.empty?
17
+ message = XmlSimple.xml_in @exception.response.body
18
+ message['Error'].first['Message'].each do |msg|
19
+ case msg
20
+ when 'No updates are to be performed.'
21
+ @logger.info msg
22
+ when /Template requires parameter(.*)/
23
+ @logger.info msg
24
+ when /^Stack:(.*) does not exist$/
25
+ @logger.error msg
26
+ raise Exceptions::UnknownStack.new msg
27
+ else
28
+ @logger.error msg
29
+ raise Exceptions::CloudFormationError.new msg
30
+ end
31
+ end
22
32
  else
23
- @logger.error msg
24
- raise Exceptions::CloudFormationError.new msg
33
+ @logger.error "CloudFormation returned blank xml EXCEPTION => #{@exception.response.body}"
34
+ raise Exceptions::CloudFormationError.new "Cloudformation returned blank xml"
25
35
  end
36
+ else
37
+ @logger.error "Unknown exception from cloudformation #{@exception.inspect}"
38
+ raise Exceptions::CloudFormationError.new "Unknown exception from cloudformation"
26
39
  end
27
40
  end
28
-
29
41
  end
30
42
  end
31
43
  end
@@ -28,8 +28,11 @@ module SimpleDeploy
28
28
  status.set_deployment_in_progress
29
29
 
30
30
  @logger.info 'Starting deployment.'
31
- executer.execute :sudo => true,
32
- :command => deploy_command
31
+ return_val = executer.execute :sudo => true,
32
+ :command => deploy_command
33
+
34
+ return false unless return_val
35
+
33
36
  @logger.info 'Deployment complete.'
34
37
 
35
38
  status.unset_deployment_in_progress
@@ -91,6 +91,11 @@ module SimpleDeploy
91
91
  end
92
92
 
93
93
  def destroy
94
+ unless exists?
95
+ @logger.error "#{@name} does not exist"
96
+ return false
97
+ end
98
+
94
99
  if attributes['protection'] != 'on'
95
100
  stack_destroyer.destroy
96
101
  @entry.delete_attributes
@@ -1,3 +1,3 @@
1
1
  module SimpleDeploy
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6.beta.1"
3
3
  end
@@ -14,10 +14,13 @@ describe SimpleDeploy::AWS::CloudFormation::Error do
14
14
  @exception_stub2 = stub 'Excon::Response'
15
15
  @exception_stub2.stub(:response).and_return(@exception_stub2)
16
16
  @exception_stub2.stub(:body).and_return('<opt><Error><Message>Oops.</Message></Error></opt>')
17
-
18
17
  @exception_stub3 = stub 'Excon::Response'
19
18
  @exception_stub3.stub(:response).and_return(@exception_stub3)
20
19
  @exception_stub3.stub(:body).and_return('<opt><Error><Message>Stack:test does not exist</Message></Error></opt>')
20
+
21
+ @exception_stub4 = stub 'Excon::Response'
22
+ @exception_stub4.stub(:response).and_return(@exception_stub4)
23
+ @exception_stub4.stub(:body).and_return('')
21
24
  end
22
25
 
23
26
  describe 'process' do
@@ -26,6 +29,11 @@ describe SimpleDeploy::AWS::CloudFormation::Error do
26
29
  expect { error.process }.to_not raise_error SimpleDeploy::Exceptions::CloudFormationError
27
30
  end
28
31
 
32
+ it 'should raise an error if the exception is blank' do
33
+ error = SimpleDeploy::AWS::CloudFormation::Error.new :exception => @exception_stub4
34
+ expect { error.process }.to raise_error SimpleDeploy::Exceptions::CloudFormationError
35
+ end
36
+
29
37
  it 'should re-raise unkonwn errors as SimpleDeploy::CloudFormationError' do
30
38
  error = SimpleDeploy::AWS::CloudFormation::Error.new :exception => @exception_stub2
31
39
 
@@ -110,7 +110,7 @@ describe SimpleDeploy::Stack::Deployment do
110
110
  before do
111
111
  @attributes['app_encrypted'] = 'true'
112
112
  @execute_mock.should_receive(:execute).
113
- with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz.gpg PRIMARY_HOST=10.1.2.3 /tmp/script"} )
113
+ with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz.gpg PRIMARY_HOST=10.1.2.3 /tmp/script"} ).and_return(true)
114
114
  end
115
115
 
116
116
  it "should deploy if the stack is clear to deploy" do
@@ -137,7 +137,7 @@ describe SimpleDeploy::Stack::Deployment do
137
137
  context "when unencrypted" do
138
138
  before do
139
139
  @execute_mock.should_receive(:execute).
140
- with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz PRIMARY_HOST=10.1.2.3 /tmp/script"} )
140
+ with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz PRIMARY_HOST=10.1.2.3 /tmp/script"} ).and_return(true)
141
141
  end
142
142
 
143
143
  it "should deploy if the stack is clear to deploy" do
data/spec/stack_spec.rb CHANGED
@@ -143,6 +143,7 @@ describe SimpleDeploy::Stack do
143
143
  end
144
144
 
145
145
  it "should destroy if the stack is not protected" do
146
+ @stack.stub(:exists?).and_return(true)
146
147
  @entry_mock.should_receive(:delete_attributes)
147
148
 
148
149
  SimpleDeploy::StackReader.should_receive(:new).
@@ -158,6 +159,7 @@ describe SimpleDeploy::Stack do
158
159
  end
159
160
 
160
161
  it "should not destroy if the stack is protected" do
162
+ @stack.stub(:exists?).and_return(true)
161
163
  @entry_mock.should_receive(:delete_attributes).never
162
164
 
163
165
  SimpleDeploy::StackReader.should_receive(:new).
@@ -170,6 +172,7 @@ describe SimpleDeploy::Stack do
170
172
  end
171
173
 
172
174
  it "should destroy if protection is undefined" do
175
+ @stack.stub(:exists?).and_return(true)
173
176
  @entry_mock.should_receive(:delete_attributes)
174
177
 
175
178
  SimpleDeploy::StackReader.should_receive(:new).
@@ -183,6 +186,13 @@ describe SimpleDeploy::Stack do
183
186
 
184
187
  @stack.destroy.should be_true
185
188
  end
189
+
190
+ it "should not destroy if stack does not exist" do
191
+ @stack.stub(:exists?).and_return(false)
192
+ @entry_mock.should_receive(:delete_attributes).never
193
+ @stack_destroyer_mock.should_receive(:destroy).never
194
+ @stack.destroy.should_not be_true
195
+ end
186
196
  end
187
197
 
188
198
  describe 'instances' do
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
5
- prerelease:
4
+ version: 0.7.6.beta.1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brett Weaver
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fakefs
16
- requirement: &70113953516080 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.4.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70113953516080
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.2
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &70113953514780 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70113953514780
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &70113953529640 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 2.13.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70113953529640
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: simplecov
49
- requirement: &70113953528660 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 0.7.1
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70113953528660
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.7.1
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: timecop
60
- requirement: &70113953528020 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,21 +85,31 @@ dependencies:
65
85
  version: 0.6.1
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70113953528020
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.6.1
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: capistrano
71
- requirement: &70113953527100 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
- - - =
99
+ - - '='
75
100
  - !ruby/object:Gem::Version
76
101
  version: 2.13.5
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70113953527100
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 2.13.5
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: esbit
82
- requirement: &70113953525280 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,40 +117,60 @@ dependencies:
87
117
  version: 0.0.4
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *70113953525280
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.0.4
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: trollop
93
- requirement: &70113953523220 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
- - - =
131
+ - - '='
97
132
  - !ruby/object:Gem::Version
98
133
  version: '2.0'
99
134
  type: :runtime
100
135
  prerelease: false
101
- version_requirements: *70113953523220
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - '='
140
+ - !ruby/object:Gem::Version
141
+ version: '2.0'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: fog
104
- requirement: &70113953537360 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
- - - =
147
+ - - '='
108
148
  - !ruby/object:Gem::Version
109
149
  version: 1.10.0
110
150
  type: :runtime
111
151
  prerelease: false
112
- version_requirements: *70113953537360
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - '='
156
+ - !ruby/object:Gem::Version
157
+ version: 1.10.0
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: xml-simple
115
- requirement: &70113953531880 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
- - - =
163
+ - - '='
119
164
  - !ruby/object:Gem::Version
120
165
  version: 1.1.2
121
166
  type: :runtime
122
167
  prerelease: false
123
- version_requirements: *70113953531880
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.1.2
124
174
  description: Opinionated gem for Managing AWS Cloud Formation stacks and deploying
125
175
  updates to Instances.
126
176
  email:
@@ -246,21 +296,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
296
  - - ! '>='
247
297
  - !ruby/object:Gem::Version
248
298
  version: '0'
249
- segments:
250
- - 0
251
- hash: -3918312770132842025
252
299
  required_rubygems_version: !ruby/object:Gem::Requirement
253
300
  none: false
254
301
  requirements:
255
- - - ! '>='
302
+ - - ! '>'
256
303
  - !ruby/object:Gem::Version
257
- version: '0'
258
- segments:
259
- - 0
260
- hash: -3918312770132842025
304
+ version: 1.3.1
261
305
  requirements: []
262
306
  rubyforge_project: simple_deploy
263
- rubygems_version: 1.8.16
307
+ rubygems_version: 1.8.24
264
308
  signing_key:
265
309
  specification_version: 3
266
310
  summary: Opinionated gem for AWS resource management.