rubycfn 0.4.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/rubycfn/version.rb +1 -1
- data/lib/rubycfn.rb +3 -13
- data/spec/lib/rubycfn_spec.rb +64 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77a1afcae7e2469088c77ddfdacc834ceb5dcedb
|
4
|
+
data.tar.gz: d4fbf293e830231a08448ae01c85930708a0da66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dff45cf27402459563b2148092d9c4328e61ae189cbeffcbe33330b852fe70c580cf32369b2c2b03b96c7aa4f6f22cd1486011a40573afe330c7590f6a4927d5
|
7
|
+
data.tar.gz: 095172e5e1aec34e99b439c3d253e359c29923171bd4473fddb913d04fafea3c8b865c40512597b2a11fd2984563fd4975fd98dec18f3cbc256e4563ac7a3a34
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
All notable changes to Rubycfn will be documented in this file.
|
3
3
|
This project uses [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
-
## 0.4.
|
5
|
+
## 0.4.2 (Next Release)
|
6
|
+
|
7
|
+
## 0.4.1
|
8
|
+
|
9
|
+
* Fixed bug with DependsOn not being rendered correctly on multiple instances of resource -- [@dennisvink][@dennisvink]
|
10
|
+
* Added specs for Ref and Fn::GetAtt transformations with strings and symbols -- [@dennisvink][@dennisvink]
|
6
11
|
|
7
12
|
## 0.4.0
|
8
13
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -61,7 +61,7 @@ __________ ____ __________________.___._________ _____________________
|
|
61
61
|
| _/ | /| | _// | |/ \ \/ | __) | | _/
|
62
62
|
| | \ | / | | \\____ |\ \____| \ | | \
|
63
63
|
|____|_ /______/ |______ // ______| \______ /\___ / |______ /
|
64
|
-
\/ \/ \/ \/ \/ \/ [v0.4.
|
64
|
+
\/ \/ \/ \/ \/ \/ [v0.4.1]
|
65
65
|
Project name? example
|
66
66
|
Account ID? 1234567890
|
67
67
|
Select region EU (Frankfurt)
|
data/lib/rubycfn/version.rb
CHANGED
data/lib/rubycfn.rb
CHANGED
@@ -407,21 +407,12 @@ module Rubycfn
|
|
407
407
|
# If the argument is a string, create an array out of it with a single element
|
408
408
|
arguments[:depends_on] = arguments[:depends_on].class == Array && arguments[:depends_on] || [arguments[:depends_on]]
|
409
409
|
|
410
|
-
# `r.depends_on` is used to amend depends_on with resources with dynamic names
|
411
|
-
# Here we add them to arguments[:depends_on]
|
412
|
-
to_amend = TOPLEVEL_BINDING.eval("@depends_on")
|
413
|
-
unless to_amend.nil?
|
414
|
-
to_amend = to_amend.class == String && [to_amend] || to_amend
|
415
|
-
to_amend.each do |amend|
|
416
|
-
arguments[:depends_on].push(amend)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
TOPLEVEL_BINDING.eval("@depends_on = []")
|
420
|
-
|
421
410
|
# Finally, we render the DependsOn array
|
422
411
|
arguments[:depends_on].map! { |resource| resource.class == String && resource.to_s || resource.to_s.split("_").map(&:capitalize).join }
|
423
412
|
end
|
424
413
|
|
414
|
+
arguments[:depends_on] ||= []
|
415
|
+
rendered_depends_on = TOPLEVEL_BINDING.eval("@depends_on").nil? && arguments[:depends_on] || arguments[:depends_on] + TOPLEVEL_BINDING.eval("@depends_on")
|
425
416
|
res = {
|
426
417
|
"#{name.to_s}#{i.zero? ? "" : resource_postpend}": {
|
427
418
|
Properties: TOPLEVEL_BINDING.eval("@properties"),
|
@@ -430,12 +421,11 @@ module Rubycfn
|
|
430
421
|
UpdatePolicy: arguments[:update_policy],
|
431
422
|
UpdateReplacePolicy: arguments[:update_replace_policy],
|
432
423
|
Metadata: arguments[:metadata],
|
433
|
-
DependsOn:
|
424
|
+
DependsOn: rendered_depends_on,
|
434
425
|
DeletionPolicy: arguments[:deletion_policy],
|
435
426
|
CreationPolicy: arguments[:creation_policy]
|
436
427
|
}
|
437
428
|
}
|
438
|
-
arguments[:depends_on] = []
|
439
429
|
TOPLEVEL_BINDING.eval("@aws_resources = @aws_resources.deep_merge(#{res})")
|
440
430
|
end
|
441
431
|
TOPLEVEL_BINDING.eval("@depends_on = []")
|
data/spec/lib/rubycfn_spec.rb
CHANGED
@@ -20,9 +20,13 @@ describe Rubycfn do
|
|
20
20
|
"WillReplace": true
|
21
21
|
}
|
22
22
|
},
|
23
|
-
amount: 2 do |r|
|
24
|
-
r.depends_on [ "barFoo", :bar_foo ]
|
23
|
+
amount: 2 do |r, index|
|
24
|
+
r.depends_on [ "barFoo", :bar_foo ] unless index.positive?
|
25
25
|
r.property(:name) { "RSpec" }
|
26
|
+
r.property(:security_group_id) { :rspec_security_group.ref }
|
27
|
+
r.property(:some_other_ref) { "rSpecSecurityGroup".ref }
|
28
|
+
r.property(:some_arn) { :rspec_resource.ref(:arn) }
|
29
|
+
r.property(:some_other_arn) { :rspec_resource.ref("FooBar") }
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -54,6 +58,8 @@ describe Rubycfn do
|
|
54
58
|
subject { resources }
|
55
59
|
|
56
60
|
it { should have_key "RspecResourceName" }
|
61
|
+
it { should have_key "RspecResourceName2" }
|
62
|
+
it { should_not have_key "RspecResourceName3" }
|
57
63
|
|
58
64
|
context "has resource type" do
|
59
65
|
let(:resource) { resources["RspecResourceName"] }
|
@@ -71,6 +77,45 @@ describe Rubycfn do
|
|
71
77
|
it { should eq ["FooBar", "fooBar", "barFoo", "BarFoo"] }
|
72
78
|
end
|
73
79
|
|
80
|
+
context "has correct properties" do
|
81
|
+
let(:properties) { resource["Properties"] }
|
82
|
+
subject { properties }
|
83
|
+
|
84
|
+
it { should have_key "Name" }
|
85
|
+
it { should have_key "SecurityGroupId" }
|
86
|
+
it { should have_key "SomeOtherRef" }
|
87
|
+
it { should have_key "SomeArn" }
|
88
|
+
it { should have_key "SomeOtherArn" }
|
89
|
+
|
90
|
+
context "ref symbol is rendered correctly" do
|
91
|
+
let(:ref_symbol) { properties["SecurityGroupId"] }
|
92
|
+
subject { ref_symbol }
|
93
|
+
|
94
|
+
it { should eq JSON.parse({ Ref: "RspecSecurityGroup" }.to_json) }
|
95
|
+
end
|
96
|
+
|
97
|
+
context "ref string is rendered correctly" do
|
98
|
+
let(:ref_string) { properties["SomeOtherRef"] }
|
99
|
+
subject { ref_string }
|
100
|
+
|
101
|
+
it { should eq JSON.parse({ Ref: "rSpecSecurityGroup" }.to_json) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context "Fn:GetAtt with symbol is rendered correctly" do
|
105
|
+
let(:fngetatt_symbol) { properties["SomeArn"] }
|
106
|
+
subject { fngetatt_symbol }
|
107
|
+
|
108
|
+
it { should eq JSON.parse({ "Fn::GetAtt": ["RspecResource", "Arn"] }.to_json) }
|
109
|
+
end
|
110
|
+
|
111
|
+
context "Fn:GetAtt with string is rendered correctly" do
|
112
|
+
let(:fngetatt_string) { properties["SomeOtherArn"] }
|
113
|
+
subject { fngetatt_string }
|
114
|
+
|
115
|
+
it { should eq JSON.parse({ "Fn::GetAtt": ["RspecResource", "FooBar"] }.to_json) }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
74
119
|
context "resource type is correct" do
|
75
120
|
let(:type) { resource["Type"] }
|
76
121
|
subject { type }
|
@@ -89,7 +134,23 @@ describe Rubycfn do
|
|
89
134
|
let(:update_policy) { resource["UpdatePolicy"] }
|
90
135
|
subject { update_policy }
|
91
136
|
|
92
|
-
it { should
|
137
|
+
it { should eq JSON.parse({ AutoScalingReplacingUpdate: { WillReplace: true }}.to_json) }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
context "second resource does not have depends_on" do
|
141
|
+
let(:resource) { resources["RspecResourceName2"] }
|
142
|
+
subject { resource }
|
143
|
+
|
144
|
+
it { should have_key "DependsOn" }
|
145
|
+
it { should have_key "Type" }
|
146
|
+
it { should have_key "Properties" }
|
147
|
+
it { should have_key "UpdatePolicy"}
|
148
|
+
|
149
|
+
context "second resource renders only the initial depends_on resources" do
|
150
|
+
let(:depends_on) { resource["DependsOn"] }
|
151
|
+
subject { depends_on }
|
152
|
+
|
153
|
+
it { should eq ["FooBar", "fooBar"] }
|
93
154
|
end
|
94
155
|
end
|
95
156
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Vink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: neatjson
|