stackup 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd8f6344aa29806003cac476d52ecd7070747ec3
4
- data.tar.gz: 1a64e7205d279d0e7922171de005ac6ddcbb08ef
3
+ metadata.gz: 4c9c28add918e16fcf983d251ccc71266f985fee
4
+ data.tar.gz: 9d2254d1f66e6c89b112b1c9c8af9d70c0450aa7
5
5
  SHA512:
6
- metadata.gz: abbf1538c8f0a04dcbd72b180803f7eb9211c07ec74eda51078135f40fd31088eaf6a3442688a6a92cee886799374475f7c4ca5ea9a350fc6fb6b6ea2ccc7b33
7
- data.tar.gz: 6fd7cb6adb0b1bd846ab7a347be74f630a4ac6514db282d1f5cd3073991ce0155f80b09b100e32fbcd965f1ad30b6ab6d9caf9c7e0342756d6ee7b9c8a34dee8
6
+ metadata.gz: 277e194f8345b2cde8bbc8649309ef3c9487982e69a79b9ff290a4d0d1b595fa91866c446b302deac95ebf24e43d53d86cd35063d9b31746d7d9eca8a74207f2
7
+ data.tar.gz: f0189757457cd35688b220f6ee22240a4224740321b856821d3d8df162f527afc289451e61d4a1f1a3816c3e5db9cbf94e8031024ec378fbf11643a9d07bb990
data/CHANGES.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 1.1.0 (2017-02-23)
1
+ ## 1.1.1 (2017-02-23)
2
2
 
3
3
  * The `stackup` CLI now allows stack template and policy documents to be specified as URLs.
4
4
  * Template URL must point to a template stored in an Amazon S3 bucket, e.g. `https://s3-ap-southeast-2.amazonaws.com/bucket/template.json`.
data/bin/stackup CHANGED
@@ -132,7 +132,7 @@ Clamp do
132
132
  def parameters_from_files
133
133
  parameter_sources.map { |src|
134
134
  Stackup::Parameters.new(src.data).to_hash
135
- }.inject(:merge)
135
+ }.inject({}, :merge)
136
136
  end
137
137
 
138
138
  subcommand "status", "Print stack status." do
@@ -179,7 +179,7 @@ Clamp do
179
179
  end
180
180
  options = {}
181
181
  if template_source
182
- if is_s3_url?(template_source.location)
182
+ if template_source.s3?
183
183
  options[:template_url] = template_source.location
184
184
  else
185
185
  options[:template] = template_source.data
@@ -189,7 +189,7 @@ Clamp do
189
189
  options[:parameters] = parameters
190
190
  options[:tags] = tag_source.data if tag_source
191
191
  if policy_source
192
- if is_s3_url?(policy_source.location)
192
+ if policy_source.s3?
193
193
  options[:stack_policy_url] = policy_source.location
194
194
  else
195
195
  options[:stack_policy] = policy_source.data
@@ -216,10 +216,6 @@ Clamp do
216
216
  end
217
217
  end
218
218
 
219
- def is_s3_url?(location)
220
- location =~ %r{^https://s3\w*.amazonaws.com}
221
- end
222
-
223
219
  end
224
220
 
225
221
  subcommand "diff", "Compare template/params to current stack." do
@@ -14,6 +14,11 @@ module Stackup
14
14
 
15
15
  attr_reader :location
16
16
 
17
+ def s3?
18
+ uri.scheme == "https" &&
19
+ uri.host =~ %r{(^|\.)s3(-\w+-\w+-\d)?\.amazonaws\.com$}
20
+ end
21
+
17
22
  def body
18
23
  @body ||= read
19
24
  end
@@ -38,8 +43,12 @@ module Stackup
38
43
  end
39
44
  rescue Errno::ENOENT
40
45
  raise ReadError, "no such file: #{location.inspect}"
46
+ rescue Errno::ECONNREFUSED => e
47
+ raise ReadError, "cannot read #{location.inspect} - #{e.message}"
41
48
  rescue OpenURI::HTTPError => e
42
- raise ReadError, "#{e}: #{location.inspect}"
49
+ raise ReadError, "cannot read #{location.inspect} - #{e.message}"
50
+ rescue SocketError => e
51
+ raise ReadError, "cannot read #{location.inspect} - #{e.message}"
43
52
  end
44
53
 
45
54
  def parse_body
@@ -1,5 +1,5 @@
1
1
  module Stackup
2
2
 
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
 
5
5
  end
@@ -12,7 +12,7 @@ describe Stackup::Source do
12
12
 
13
13
  let(:json_file) { File.join(example_dir, "template.json") }
14
14
 
15
- subject(:source) { described_class.new(json_file) }
15
+ subject(:src) { described_class.new(json_file) }
16
16
 
17
17
  describe "#body" do
18
18
 
@@ -30,13 +30,17 @@ describe Stackup::Source do
30
30
 
31
31
  end
32
32
 
33
+ it "is not S3" do
34
+ expect(subject).not_to be_s3
35
+ end
36
+
33
37
  end
34
38
 
35
39
  context "from a YAML file" do
36
40
 
37
41
  let(:yaml_file) { File.join(example_dir, "template.yml") }
38
42
 
39
- subject(:source) { described_class.new(yaml_file) }
43
+ subject(:src) { described_class.new(yaml_file) }
40
44
 
41
45
  describe "#body" do
42
46
 
@@ -60,7 +64,7 @@ describe Stackup::Source do
60
64
 
61
65
  let(:bogus_file) { "notreallythere.json" }
62
66
 
63
- subject(:source) { described_class.new(bogus_file) }
67
+ subject(:src) { described_class.new(bogus_file) }
64
68
 
65
69
  describe "#body" do
66
70
 
@@ -72,4 +76,54 @@ describe Stackup::Source do
72
76
 
73
77
  end
74
78
 
79
+ context "with an HTTP URL" do
80
+
81
+ let(:url) { "https://example.com/template.json" }
82
+
83
+ subject(:src) { described_class.new(url) }
84
+
85
+ it "is not S3" do
86
+ expect(subject).not_to be_s3
87
+ end
88
+
89
+ end
90
+
91
+ context "with an S3 URL" do
92
+
93
+ let(:s3_url) { "https://s3.amazonaws.com/bucket/template.json" }
94
+
95
+ subject(:src) { described_class.new(s3_url) }
96
+
97
+ context "with bucket in path" do
98
+
99
+ let(:s3_url) { "https://s3.amazonaws.com/bucket/template.json" }
100
+
101
+ it "is S3" do
102
+ expect(subject).to be_s3
103
+ end
104
+
105
+ end
106
+
107
+ context "with bucket in host" do
108
+
109
+ let(:s3_url) { "https://bucket.s3.amazonaws.com/template.json" }
110
+
111
+ it "is S3" do
112
+ expect(subject).to be_s3
113
+ end
114
+
115
+ end
116
+
117
+ context "with bucket region" do
118
+
119
+ let(:s3_url) { "https://bucket.s3-ap-northeast-3.amazonaws.com/template.json" }
120
+
121
+ it "is S3" do
122
+ expect(subject).to be_s3
123
+ end
124
+
125
+ end
126
+
127
+ end
128
+
75
129
  end
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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams