stackster 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use ruby-1.9.3-p194@stackster --create
1
+ rvm use ruby-1.9.3-p327@stackster --create
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ ## v0.4.0
2
+
3
+ * Raise stackster exception as opposed to exit on CF errors
4
+ * Creating base exceptions class
5
+ * Updating rvm to ruby 1.9.3-p327
6
+
1
7
  ## v0.3.2
2
8
 
3
9
  * Removed the logger gem dependency
@@ -1,5 +1,6 @@
1
1
  require "stackster/aws"
2
2
  require "stackster/entry"
3
+ require "stackster/exceptions"
3
4
  require "stackster/stack"
4
5
  require "stackster/instance"
5
6
  require "stackster/logger"
@@ -17,9 +17,12 @@ module Stackster
17
17
  case msg
18
18
  when 'No updates are to be performed.'
19
19
  @logger.info msg
20
+ when /^Stack:(.*) does not exist$/
21
+ @logger.error msg
22
+ raise Stackster::Exceptions::UnknownStack.new msg
20
23
  else
21
24
  @logger.error msg
22
- exit 1
25
+ raise Stackster::Exceptions::CloudFormationError.new msg
23
26
  end
24
27
  end
25
28
  end
@@ -0,0 +1,17 @@
1
+ module Stackster
2
+ module Exceptions
3
+ class Base < RuntimeError
4
+ attr_accessor :message
5
+
6
+ def initialize(message="")
7
+ @message = message
8
+ end
9
+ end
10
+
11
+ class CloudFormationError < Base
12
+ end
13
+
14
+ class UnknownStack < Base
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Stackster
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -13,6 +13,10 @@ describe Stackster do
13
13
  @exception_stub2 = stub 'Excon::Response'
14
14
  @exception_stub2.stub(:response).and_return(@exception_stub2)
15
15
  @exception_stub2.stub(:body).and_return('<opt><Error><Message>Oops.</Message></Error></opt>')
16
+
17
+ @exception_stub3 = stub 'Excon::Response'
18
+ @exception_stub3.stub(:response).and_return(@exception_stub3)
19
+ @exception_stub3.stub(:body).and_return('<opt><Error><Message>Stack:test does not exist</Message></Error></opt>')
16
20
  end
17
21
 
18
22
  describe 'process' do
@@ -23,17 +27,31 @@ describe Stackster do
23
27
  error.process
24
28
  end
25
29
 
26
- it 'should process general messages' do
30
+ it 'should re-raise unkonwn errors as Stackster::CloudFormationError' do
27
31
  @logger_mock.should_receive(:error).with('Oops.')
28
32
 
29
33
  error = Stackster::AWS::CloudFormation::Error.new :exception => @exception_stub2, :config => @config_stub
30
34
 
35
+ lambda { error.process }.should raise_error Stackster::Exceptions::CloudFormationError
36
+ end
37
+
38
+ it 'should re-raise unkonwn errors as Stackster::CloudFormationError and set mesg' do
39
+ @logger_mock.should_receive(:error).with('Oops.')
40
+
41
+ error = Stackster::AWS::CloudFormation::Error.new :exception => @exception_stub2, :config => @config_stub
31
42
  begin
32
43
  error.process
33
- fail 'should have exited'
34
- rescue SystemExit => e
35
- e.status.should == 1
44
+ rescue Stackster::Exceptions::CloudFormationError => e
45
+ e.message.should == "Oops."
36
46
  end
37
47
  end
48
+
49
+ it 'should reaise stck unkown messages as Stackster::UnknownStack' do
50
+ @logger_mock.should_receive(:error).with('Stack:test does not exist')
51
+
52
+ error = Stackster::AWS::CloudFormation::Error.new :exception => @exception_stub3, :config => @config_stub
53
+ lambda { error.process }.should raise_error Stackster::Exceptions::UnknownStack
54
+ end
55
+
38
56
  end
39
57
  end
@@ -37,16 +37,19 @@ describe Stackster do
37
37
  @cf.create(@args)
38
38
  end
39
39
 
40
- it "should trap exceptions" do
40
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
41
41
  @cf_mock.should_receive(:create_stack).with('my_stack',
42
42
  { 'Capabilities' => ['CAPABILITY_IAM'],
43
43
  'TemplateBody' => 'my_template',
44
44
  'Parameters' => { 'parameter1' => 'my_param' }
45
45
  }).and_raise(@exception)
46
+
46
47
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
47
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
48
+ with(:config => @config_stub, :exception => @exception).
49
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
48
50
 
49
- @cf.create(@args).should == 'Processed Error'
51
+ lambda { @cf.create @args }.
52
+ should raise_error Stackster::Exceptions::CloudFormationError
50
53
  end
51
54
  end
52
55
 
@@ -61,16 +64,18 @@ describe Stackster do
61
64
  @cf.update(@args)
62
65
  end
63
66
 
64
- it "should trap exceptions" do
67
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
65
68
  @cf_mock.should_receive(:update_stack).with('my_stack',
66
69
  { 'Capabilities' => ['CAPABILITY_IAM'],
67
70
  'TemplateBody' => 'my_template',
68
71
  'Parameters' => { 'parameter1' => 'my_param' }
69
72
  }).and_raise(@exception)
70
73
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
71
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
74
+ with(:config => @config_stub, :exception => @exception).
75
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
72
76
 
73
- @cf.update(@args).should == 'Processed Error'
77
+ lambda { @cf.update(@args) }.
78
+ should raise_error Stackster::Exceptions::CloudFormationError
74
79
  end
75
80
  end
76
81
 
@@ -82,12 +87,16 @@ describe Stackster do
82
87
  @cf.destroy('my_stack')
83
88
  end
84
89
 
85
- it "should trap exceptions" do
86
- @cf_mock.should_receive(:delete_stack).with('my_stack').and_raise(@exception)
90
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
91
+ @cf_mock.should_receive(:delete_stack).
92
+ with('my_stack').
93
+ and_raise @exception
87
94
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
88
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
95
+ with(:config => @config_stub, :exception => @exception).
96
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
89
97
 
90
- @cf.destroy('my_stack').should == 'Processed Error'
98
+ lambda { @cf.destroy('my_stack') }.
99
+ should raise_error Stackster::Exceptions::CloudFormationError
91
100
  end
92
101
  end
93
102
 
@@ -99,12 +108,16 @@ describe Stackster do
99
108
  @cf.describe_stack('my_stack').should == [{'StackStatus' => 'green', 'Outputs' => [{'key' => 'value'}]}]
100
109
  end
101
110
 
102
- it "should trap exceptions" do
103
- @cf_mock.should_receive(:describe_stacks).with('StackName' => 'my_stack').and_raise(@exception)
111
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
112
+ @cf_mock.should_receive(:describe_stacks).
113
+ with('StackName' => 'my_stack').
114
+ and_raise @exception
104
115
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
105
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
116
+ with(:config => @config_stub, :exception => @exception).
117
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
106
118
 
107
- @cf.describe_stack('my_stack').should == 'Processed Error'
119
+ lambda { @cf.describe_stack('my_stack') }.
120
+ should raise_error Stackster::Exceptions::CloudFormationError
108
121
  end
109
122
  end
110
123
 
@@ -115,12 +128,16 @@ describe Stackster do
115
128
  @cf.stack_resources('my_stack').should == [{'StackName' => 'my_stack'}]
116
129
  end
117
130
 
118
- it "should trap exceptions" do
119
- @cf_mock.should_receive(:describe_stack_resources).with('StackName' => 'my_stack').and_raise(@exception)
131
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
132
+ @cf_mock.should_receive(:describe_stack_resources).
133
+ with('StackName' => 'my_stack').
134
+ and_raise @exception
120
135
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
121
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
136
+ with(:config => @config_stub, :exception => @exception).
137
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
122
138
 
123
- @cf.stack_resources('my_stack').should == 'Processed Error'
139
+ lambda { @cf.stack_resources('my_stack') }.
140
+ should raise_error Stackster::Exceptions::CloudFormationError
124
141
  end
125
142
  end
126
143
 
@@ -131,12 +148,17 @@ describe Stackster do
131
148
  @cf.stack_events('my_stack', 2).should == ['event1', 'event2']
132
149
  end
133
150
 
134
- it "should trap exceptions" do
135
- @cf_mock.should_receive(:describe_stack_events).with('my_stack').and_raise(@exception)
151
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
152
+ @cf_mock.should_receive(:describe_stack_events).
153
+ with('my_stack').
154
+ and_raise @exception
155
+
136
156
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
137
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
157
+ with(:config => @config_stub, :exception => @exception).
158
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
138
159
 
139
- @cf.stack_events('my_stack', 2).should == 'Processed Error'
160
+ lambda { @cf.stack_events('my_stack', 2) }.
161
+ should raise_error Stackster::Exceptions::CloudFormationError
140
162
  end
141
163
  end
142
164
 
@@ -163,12 +185,16 @@ describe Stackster do
163
185
  @cf.template('my_stack').should == '{EIP: "string"}'
164
186
  end
165
187
 
166
- it "should trap exceptions" do
167
- @cf_mock.should_receive(:get_template).with('my_stack').and_raise(@exception)
188
+ it "should trap and re-raise exceptions as Stackster::Exceptions::CloudFormationError" do
189
+ @cf_mock.should_receive(:get_template).
190
+ with('my_stack').
191
+ and_raise @exception
168
192
  Stackster::AWS::CloudFormation::Error.should_receive(:new).
169
- with(:config => @config_stub, :exception => @exception).and_return(@error_stub)
193
+ with(:config => @config_stub, :exception => @exception).
194
+ and_raise Stackster::Exceptions::CloudFormationError.new('failed')
170
195
 
171
- @cf.template('my_stack').should == 'Processed Error'
196
+ lambda { @cf.template('my_stack') }.
197
+ should raise_error Stackster::Exceptions::CloudFormationError
172
198
  end
173
199
  end
174
200
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70363866364540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *70363866364540
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: rspec
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70363866362780 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ~>
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: 2.11.0
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 2.11.0
35
+ version_requirements: *70363866362780
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: simplecov
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &70363866361660 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ~>
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: 0.6.4
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 0.6.4
46
+ version_requirements: *70363866361660
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: timecop
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &70363866360020 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ~>
@@ -69,60 +54,40 @@ dependencies:
69
54
  version: 0.5.3
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 0.5.3
57
+ version_requirements: *70363866360020
78
58
  - !ruby/object:Gem::Dependency
79
59
  name: fog
80
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &70363866374520 !ruby/object:Gem::Requirement
81
61
  none: false
82
62
  requirements:
83
- - - '='
63
+ - - =
84
64
  - !ruby/object:Gem::Version
85
65
  version: 1.6.0
86
66
  type: :runtime
87
67
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - '='
92
- - !ruby/object:Gem::Version
93
- version: 1.6.0
68
+ version_requirements: *70363866374520
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: trollop
96
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &70363866373260 !ruby/object:Gem::Requirement
97
72
  none: false
98
73
  requirements:
99
- - - '='
74
+ - - =
100
75
  - !ruby/object:Gem::Version
101
76
  version: '2.0'
102
77
  type: :runtime
103
78
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - '='
108
- - !ruby/object:Gem::Version
109
- version: '2.0'
79
+ version_requirements: *70363866373260
110
80
  - !ruby/object:Gem::Dependency
111
81
  name: xml-simple
112
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &70363866371480 !ruby/object:Gem::Requirement
113
83
  none: false
114
84
  requirements:
115
- - - '='
85
+ - - =
116
86
  - !ruby/object:Gem::Version
117
87
  version: 1.1.2
118
88
  type: :runtime
119
89
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - '='
124
- - !ruby/object:Gem::Version
125
- version: 1.1.2
90
+ version_requirements: *70363866371480
126
91
  description: Thats what I do
127
92
  email:
128
93
  - brett@weav.net
@@ -150,6 +115,7 @@ files:
150
115
  - lib/stackster/config.rb
151
116
  - lib/stackster/entry.rb
152
117
  - lib/stackster/entry/entry_lister.rb
118
+ - lib/stackster/exceptions.rb
153
119
  - lib/stackster/instance.rb
154
120
  - lib/stackster/instance/instance_reader.rb
155
121
  - lib/stackster/logger.rb
@@ -195,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
161
  version: '0'
196
162
  segments:
197
163
  - 0
198
- hash: -3770927478865725038
164
+ hash: 3449585736490155171
199
165
  required_rubygems_version: !ruby/object:Gem::Requirement
200
166
  none: false
201
167
  requirements:
@@ -204,10 +170,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
170
  version: '0'
205
171
  segments:
206
172
  - 0
207
- hash: -3770927478865725038
173
+ hash: 3449585736490155171
208
174
  requirements: []
209
175
  rubyforge_project: stackster
210
- rubygems_version: 1.8.24
176
+ rubygems_version: 1.8.16
211
177
  signing_key:
212
178
  specification_version: 3
213
179
  summary: I make deployments easier