stackup 1.6.0 → 1.7.0

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
  SHA256:
3
- metadata.gz: 281a4cc419891f70b5a8251d52c080a678e21d2a76a57a0e715b478987c5d967
4
- data.tar.gz: e1848f7cccad92a7a6883f3947daa68e70d1b72ad00bfa72727f0def2590ee89
3
+ metadata.gz: 60e50e255335b7924e71a6fed889c946c3b182c2b95277056f88e2e420915f79
4
+ data.tar.gz: 816b9a71283680668fe9d3cf35c54a3a1a2516a68f0251a1771e4bba17e2cce2
5
5
  SHA512:
6
- metadata.gz: 59cd63007ce56b284e7176c82f354174bb78dec2fba84443e2b1a28465df5ed68cd0bc1ccd2474dab7572c61ebb85d9de328e12216395d0e68c8101863b0110a
7
- data.tar.gz: 3acf8d1d83307ef2851001558c7880c4d43692f740254531369713e4cb7d38f3595398195cfd8f67460b10c1bd94cd7dca08a833fdf51371ef0a1c914addcffc
6
+ metadata.gz: be56a2ae96045ace217de36cd7f82592eb2588178b314f8d68d51e6b6d16a1e66c60557e78fa5f524cb710aa42f0d64372629fe4d6b9aad65c3ddec11fe051f4
7
+ data.tar.gz: 79974fadb7ac89a76a92fa424c4cc2ef63deeec8cfd55b6eda352e965ecd84e832322eddafaaf9eb57fd3640c3744646a484954664f15cfa9bbfeda4b0eb03c8
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES
2
2
 
3
+ ## 1.7.0 (2020-11-25)
4
+
5
+ * Feature: --no-fail-on-empty-change-set
6
+
3
7
  ## 1.6.0 (2020-11-19)
4
8
 
5
9
  * Feature: Support --service-role-arn on "change-set create"
data/README.md CHANGED
@@ -218,6 +218,8 @@ The change-set name defaults to "pending", but can be overridden using `--name`.
218
218
 
219
219
  The `change-set create` subcommand, like the `up` command, supports `--service-role-arn` to specify a service role.
220
220
 
221
+ It is impossible to create a change set with no changes. By default, stackup will only return successfully if a change set was actually created, and will otherwise fail. If the `--no-fail-on-empty-change-set` option is provided, stackup will return successfully if a change set was created _or_ if no change set was created because no changes were needed.
222
+
221
223
  ## Programmatic usage
222
224
 
223
225
  Get a handle to a `Stack` object as follows:
@@ -56,6 +56,7 @@ module Stackup
56
56
  options[:change_set_name] = name
57
57
  options[:change_set_type] = stack.exists? ? "UPDATE" : "CREATE"
58
58
  force = options.delete(:force)
59
+ allow_empty_change_set = options.delete(:allow_empty_change_set)
59
60
  options[:template_body] = MultiJson.dump(options.delete(:template)) if options[:template]
60
61
  # optionally override template_body with the original template to preserve formatting (& comments in YAML)
61
62
  template_orig = options.delete(:template_orig)
@@ -73,8 +74,12 @@ module Stackup
73
74
  when /COMPLETE/
74
75
  return current.status
75
76
  when "FAILED"
76
- logger.error(current.status_reason)
77
- raise StackUpdateError, "change-set creation failed" if status == "FAILED"
77
+ if allow_empty_change_set and current.status_reason == "The submitted information didn't contain changes. Submit different information to create a change set."
78
+ return current.status_reason
79
+ else
80
+ logger.error(current.status_reason)
81
+ raise StackUpdateError, "change-set creation failed" if status == "FAILED"
82
+ end
78
83
  end
79
84
  sleep(wait_poll_interval)
80
85
  end
@@ -280,6 +280,9 @@ module Stackup
280
280
  option ["--force"], :flag,
281
281
  "replace existing change-set of the same name"
282
282
 
283
+ option ["--no-fail-on-empty-change-set"], :flag, "don't fail on empty change-set",
284
+ :attribute_name => :allow_empty_change_set
285
+
283
286
  include HasParameters
284
287
 
285
288
  option "--tags", "FILE", "stack tags file",
@@ -314,6 +317,7 @@ module Stackup
314
317
  options[:role_arn] = service_role_arn if service_role_arn
315
318
  options[:use_previous_template] = use_previous_template?
316
319
  options[:force] = force?
320
+ options[:allow_empty_change_set] = allow_empty_change_set?
317
321
  options[:capabilities] = capability_list
318
322
  options[:preserve] = preserve_template_formatting?
319
323
  report_change do
@@ -1,5 +1,5 @@
1
1
  module Stackup
2
2
 
3
- VERSION = "1.6.0".freeze
3
+ VERSION = "1.7.0".freeze
4
4
 
5
5
  end
@@ -1,15 +1,19 @@
1
1
  require "stackup/main_command"
2
2
 
3
3
  describe Stackup::MainCommand do
4
- context "change-set create --service-role-arn"
5
- it "invokes stack.change_set.create with role arn passed through" do
6
- mock_stackup = double()
7
- mock_stack = double()
8
- mock_change_set = double()
9
- allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
10
- allow(mock_stackup).to receive(:stack).and_return(mock_stack)
11
- allow(mock_stack).to receive(:change_set).and_return(mock_change_set)
12
4
 
5
+ let(:mock_change_set) { double() }
6
+
7
+ before(:example) do
8
+ mock_stackup = double()
9
+ mock_stack = double()
10
+ allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
11
+ allow(mock_stackup).to receive(:stack).and_return(mock_stack)
12
+ allow(mock_stack).to receive(:change_set).and_return(mock_change_set)
13
+ end
14
+
15
+ context "change-set create --service-role-arn" do
16
+ it "invokes stack.change_set.create with role arn passed through" do
13
17
  expected_args = {
14
18
  role_arn: "arn:aws:iam::000000000000:role/example"
15
19
  }
@@ -20,4 +24,33 @@ describe Stackup::MainCommand do
20
24
  "--template", "examples/template.yml",
21
25
  "--service-role-arn", "arn:aws:iam::000000000000:role/example"])
22
26
  end
27
+ end
28
+
29
+ context "change-set create" do
30
+ it "invokes stack.change_set.create with allow_empty_change_set nil" do
31
+ expected_args = {
32
+ allow_empty_change_set: nil
33
+ }
34
+ expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
35
+
36
+ Stackup::MainCommand.run("stackup", [
37
+ "STACK-NAME", "change-set", "create",
38
+ "--template", "examples/template.yml"])
39
+ end
40
+ end
41
+
42
+ context "change-set create --no-fail-on-empty-change-set" do
43
+ it "invokes stack.change_set.create with allow_empty_change_set true" do
44
+ expected_args = {
45
+ allow_empty_change_set: true
46
+ }
47
+ expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
48
+
49
+ Stackup::MainCommand.run("stackup", [
50
+ "STACK-NAME", "change-set", "create",
51
+ "--template", "examples/template.yml",
52
+ "--no-fail-on-empty-change-set"])
53
+ end
54
+ end
55
+
23
56
  end
@@ -429,6 +429,38 @@ describe Stackup::Stack do
429
429
 
430
430
  end
431
431
 
432
+ context "when allow_empty_change_set is nil and there are no changes" do
433
+ it "raises an exception" do
434
+ cf_client.stub_responses(:describe_change_set, [{
435
+ status: "FAILED",
436
+ status_reason: "The submitted information didn't contain changes. Submit different information to create a change set."
437
+ }])
438
+ expect { create_change_set }.to raise_error(Stackup::StackUpdateError)
439
+ end
440
+ end
441
+
442
+ context "when allow_empty_change_set is true and there are no changes" do
443
+ it "does not raise an exception" do
444
+ cf_client.stub_responses(:describe_change_set, [{
445
+ status: "FAILED",
446
+ status_reason: "The submitted information didn't contain changes. Submit different information to create a change set."
447
+ }])
448
+ options[:allow_empty_change_set] = true
449
+ expect { create_change_set }.not_to raise_error
450
+ end
451
+ end
452
+
453
+ context "when allow_empty_change_set is true and there is some other failure" do
454
+ it "raises an exception" do
455
+ cf_client.stub_responses(:describe_change_set, [{
456
+ status: "FAILED",
457
+ status_reason: "some other failure message"
458
+ }])
459
+ options[:allow_empty_change_set] = true
460
+ expect { create_change_set }.to raise_error(Stackup::StackUpdateError)
461
+ end
462
+ end
463
+
432
464
  end
433
465
 
434
466
  describe "#change_set#execute" do
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: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-19 00:00:00.000000000 Z
12
+ date: 2020-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-cloudformation