stackup 0.6.0 → 0.6.1

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: 7968636aea4da953ab3902af33236e0705ad4d26
4
- data.tar.gz: 7c1f9ad8bc8f02f9a59e0a74692c4c54548d171f
3
+ metadata.gz: 23c1e4e4d9403ef28b55daf9ee4f21fd55dabd57
4
+ data.tar.gz: 9ac49da0f9c055a4b8b0809d8f6a47da32c78238
5
5
  SHA512:
6
- metadata.gz: 2d7cfc30af2ada8982ccdb9fda1b438da8add5f759c20767304d8f5a1a71b857e5c44bb9b3084e73104990b7ea39e1e2e672db5dc606e5b2fbac345a159bd99f
7
- data.tar.gz: 62dd4d15cf71214870ff0b5ba1234b9d4c7f3f22e58724de38789c91817d4f8f8dda04cfc954f81a66b3f9a6c6d14d3cfb96fbb9fd64c0ee7f8965e02209629d
6
+ metadata.gz: 0cce0bf0091f7c66ffe43c56d4037070873b24f492f8668e33258d90a2087e56f44be1df0c875e8e8b6f9dd07c4aa20a5d56d343214a9c41ac7e43d44a1f1c5c
7
+ data.tar.gz: e7a295ae3e2f60ac369bdde9a2dad410fb033488f914218f8c973a9b2c636c1f016d2a0e1aeaaf81234157d95dec44e4f6554f67b8b5b19b46b6bbd0ffac367b
data/README.md CHANGED
@@ -15,8 +15,9 @@ Stackup provides some advantages over using `awscli` or `aws-sdk` directly:
15
15
  - A `Stack#up` facade for `create`/`update` frees you from having to know
16
16
  whether your stack already exists or not.
17
17
 
18
- - "No-op" operations - deleting a stack that doesn't exist, or updating
19
- without a template change - are handled gracefully (i.e. without error).
18
+ - Changes are (mostly) idempotent: "no-op" operations - e.g. deleting a
19
+ stack that doesn't exist, or updating without a template change - are
20
+ handled gracefully (i.e. without error).
20
21
 
21
22
  ## Installation
22
23
 
data/bin/stackup CHANGED
@@ -71,8 +71,8 @@ Clamp do
71
71
  end
72
72
 
73
73
  def report_change
74
- change = yield
75
- puts "Stack #{change}" unless change.nil?
74
+ final_status = yield
75
+ puts final_status unless final_status.nil?
76
76
  end
77
77
 
78
78
  def load_data(file)
@@ -141,8 +141,10 @@ Clamp do
141
141
  diff_data(stack.template, template)
142
142
  end
143
143
  if parameters_file
144
- parameters = hashify_parameters(load_data(parameters_file))
145
- diff_data(stack.parameters, parameters)
144
+ new_parameters = hashify_parameters(load_data(parameters_file))
145
+ existing_parameters = stack.parameters
146
+ new_parameters = existing_parameters.merge(new_parameters)
147
+ diff_data(existing_parameters.sort.to_h, new_parameters.sort.to_h)
146
148
  end
147
149
  end
148
150
 
@@ -160,7 +162,9 @@ Clamp do
160
162
  return parameters unless parameters.is_a?(Array)
161
163
  {}.tap do |result|
162
164
  parameters.each do |p|
163
- result[p["parameter_key"]] = p["parameter_value"]
165
+ key = p.fetch("ParameterKey") { p.fetch("parameter_key") }
166
+ value = p.fetch("ParameterValue") { p.fetch("parameter_value") }
167
+ result[key] = value
164
168
  end
165
169
  end
166
170
  end
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
- "parameter_key": "IndexDoc",
4
- "parameter_value": "default.htm"
3
+ "ParameterKey": "IndexDoc",
4
+ "ParameterValue": "default.htm"
5
5
  }
6
6
  ]
data/lib/stackup/stack.rb CHANGED
@@ -138,7 +138,7 @@ module Stackup
138
138
  cf_stack.delete
139
139
  end
140
140
  fail StackUpdateError, "stack delete failed" unless status == "DELETE_COMPLETE"
141
- :deleted
141
+ status
142
142
  ensure
143
143
  @stack_id = nil
144
144
  end
@@ -155,7 +155,7 @@ module Stackup
155
155
  cf_stack.cancel_update
156
156
  end
157
157
  fail StackUpdateError, "update cancel failed" unless status =~ /_COMPLETE$/
158
- :update_cancelled
158
+ status
159
159
  rescue InvalidStateError
160
160
  nil
161
161
  end
@@ -255,7 +255,7 @@ module Stackup
255
255
  cf.create_stack(options)
256
256
  end
257
257
  fail StackUpdateError, "stack creation failed" unless status == "CREATE_COMPLETE"
258
- :created
258
+ status
259
259
  end
260
260
 
261
261
  def update(options)
@@ -266,7 +266,7 @@ module Stackup
266
266
  cf_stack.update(options)
267
267
  end
268
268
  fail StackUpdateError, "stack update failed" unless status == "UPDATE_COMPLETE"
269
- :updated
269
+ status
270
270
  rescue NoUpdateRequired
271
271
  nil
272
272
  end
@@ -303,15 +303,32 @@ module Stackup
303
303
  end
304
304
 
305
305
  def normalise_parameters(arg)
306
- return arg unless arg.is_a?(Hash)
307
- arg.map do |key, value|
308
- {
309
- :parameter_key => key,
310
- :parameter_value => value
311
- }
306
+ if arg.is_a?(Hash)
307
+ return arg.map do |key, value|
308
+ {
309
+ :parameter_key => key,
310
+ :parameter_value => value
311
+ }
312
+ end
313
+ end
314
+ arg.map do |parameter|
315
+ normalise_parameter_keys(parameter)
312
316
  end
313
317
  end
314
318
 
319
+ def normalise_parameter_keys(input)
320
+ {}.tap do |output|
321
+ input.each do |key, value|
322
+ output[normalise_parameter_key(key)] = value
323
+ end
324
+ end
325
+ end
326
+
327
+ def normalise_parameter_key(s)
328
+ return s if s.is_a?(Symbol)
329
+ s.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
330
+ end
331
+
315
332
  end
316
333
 
317
334
  end
@@ -1,5 +1,5 @@
1
1
  module Stackup
2
2
 
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
 
5
5
  end
@@ -105,8 +105,8 @@ describe Stackup::Stack do
105
105
  .with(hash_including(expected_args))
106
106
  end
107
107
 
108
- it "returns :created" do
109
- expect(create_or_update).to eq(:created)
108
+ it "returns status" do
109
+ expect(create_or_update).to eq("CREATE_COMPLETE")
110
110
  end
111
111
 
112
112
  end
@@ -157,6 +157,30 @@ describe Stackup::Stack do
157
157
 
158
158
  end
159
159
 
160
+ context "with :parameters in awscli form" do
161
+
162
+ before do
163
+ options[:parameters] = [{
164
+ "ParameterKey" => "foo",
165
+ "ParameterValue" => "bar"
166
+ }]
167
+ end
168
+
169
+ it "converts them to an Array" do
170
+ expected_parameters = [
171
+ {
172
+ "parameter_key" => "foo",
173
+ "parameter_value" => "bar"
174
+ }
175
+ ]
176
+ create_or_update
177
+ expect(cf_client).to have_received(:create_stack) do |options|
178
+ expect(options[:parameters]).to eq(expected_parameters)
179
+ end
180
+ end
181
+
182
+ end
183
+
160
184
  end
161
185
 
162
186
  end
@@ -200,8 +224,8 @@ describe Stackup::Stack do
200
224
  .with(hash_including(:stack_name => unique_stack_id))
201
225
  end
202
226
 
203
- it "returns :deleted" do
204
- expect(stack.delete).to eq(:deleted)
227
+ it "returns status" do
228
+ expect(stack.delete).to eq("DELETE_COMPLETE")
205
229
  end
206
230
 
207
231
  end
@@ -256,8 +280,8 @@ describe Stackup::Stack do
256
280
 
257
281
  context "successful" do
258
282
 
259
- it "returns :updated" do
260
- expect(create_or_update).to eq(:updated)
283
+ it "returns status" do
284
+ expect(create_or_update).to eq(final_status)
261
285
  end
262
286
 
263
287
  context "if no updates are required" do
@@ -384,8 +408,8 @@ describe Stackup::Stack do
384
408
  .with(hash_including(expected_args))
385
409
  end
386
410
 
387
- it "returns :update_cancelled" do
388
- expect(stack.cancel_update).to eq(:update_cancelled)
411
+ it "returns status" do
412
+ expect(stack.cancel_update).to eq("UPDATE_ROLLBACK_COMPLETE")
389
413
  end
390
414
 
391
415
  end
data/stackup.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "bin"
22
22
  spec.executables << "stackup"
23
23
 
24
- spec.add_dependency "aws-sdk", "~> 2.0"
24
+ spec.add_dependency "aws-sdk-resources", "~> 2.0"
25
25
  spec.add_dependency "clamp", "~> 1.0"
26
26
  spec.add_dependency "console_logger"
27
27
  spec.add_dependency "diffy", "~> 3.0.5"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-18 00:00:00.000000000 Z
12
+ date: 2015-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: aws-sdk
15
+ name: aws-sdk-resources
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.4.5.1
136
+ rubygems_version: 2.5.0
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Manage CloudFormation stacks