lono 0.5.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +152 -23
- data/lib/lono.rb +1 -0
- data/lib/lono/cli.rb +3 -2
- data/lib/lono/dsl.rb +59 -12
- data/lib/lono/new.rb +4 -2
- data/lib/lono/template.rb +22 -9
- data/lib/lono/version.rb +1 -1
- data/lib/{starter_project → starter_project_json}/Gemfile +2 -1
- data/lib/{starter_project → starter_project_json}/Guardfile +0 -0
- data/lib/starter_project_json/config/lono.rb +20 -0
- data/lib/{starter_project → starter_project_json}/config/lono/api.rb +9 -9
- data/lib/{starter_project → starter_project_json}/templates/db.json.erb +1 -1
- data/lib/{starter_project → starter_project_json}/templates/partial/host_record.json.erb +0 -0
- data/lib/{starter_project → starter_project_json}/templates/partial/server.json.erb +0 -0
- data/lib/{starter_project → starter_project_json}/templates/user_data/app.sh.erb +1 -4
- data/lib/{starter_project → starter_project_json}/templates/user_data/db.sh.erb +0 -0
- data/lib/{starter_project → starter_project_json}/templates/user_data/db2.sh.erb +0 -0
- data/lib/{starter_project → starter_project_json}/templates/user_data/ruby_script.rb.erb +0 -0
- data/lib/{starter_project/templates/app.json.erb → starter_project_json/templates/web.json.erb} +1 -1
- data/lib/starter_project_yaml/Gemfile +4 -0
- data/lib/starter_project_yaml/Guardfile +12 -0
- data/lib/{starter_project → starter_project_yaml}/config/lono.rb +5 -5
- data/lib/starter_project_yaml/config/lono/api.rb +58 -0
- data/lib/starter_project_yaml/templates/db.yml.erb +148 -0
- data/lib/starter_project_yaml/templates/partial/host_record.yml.erb +14 -0
- data/lib/starter_project_yaml/templates/partial/server.yml.erb +59 -0
- data/lib/starter_project_yaml/templates/partial/user_data/bootstrap.sh.erb +5 -0
- data/lib/starter_project_yaml/templates/web.yml.erb +205 -0
- data/lono.gemspec +1 -1
- data/spec/lib/lono/dsl_spec.rb +184 -0
- data/spec/lib/lono/new_spec.rb +59 -0
- data/spec/lib/lono_spec.rb +6 -116
- data/spec/spec_helper.rb +1 -0
- metadata +42 -15
data/spec/lib/lono_spec.rb
CHANGED
@@ -3,15 +3,15 @@ require File.expand_path("../../spec_helper", __FILE__)
|
|
3
3
|
describe Lono do
|
4
4
|
before(:each) do
|
5
5
|
lono_bin = File.expand_path("../../../bin/lono", __FILE__)
|
6
|
-
@
|
7
|
-
dir = File.dirname(@
|
8
|
-
name = File.basename(@
|
6
|
+
@project_root = File.expand_path("../../../tmp/lono_project", __FILE__)
|
7
|
+
dir = File.dirname(@project_root)
|
8
|
+
name = File.basename(@project_root)
|
9
9
|
FileUtils.mkdir(dir) unless File.exist?(dir)
|
10
|
-
execute("cd #{dir} && #{lono_bin} new #{name} -f -q ")
|
10
|
+
execute("cd #{dir} && #{lono_bin} new #{name} -f -q --format json")
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:each) do
|
14
|
-
FileUtils.rm_rf(@
|
14
|
+
FileUtils.rm_rf(@project_root) unless ENV['KEEP_TMP_PROJECT']
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "bashify" do
|
@@ -79,119 +79,9 @@ describe Lono do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe "ruby specs" do
|
83
|
-
before(:each) do
|
84
|
-
dsl = Lono::DSL.new(
|
85
|
-
project_root: @project,
|
86
|
-
quiet: true
|
87
|
-
)
|
88
|
-
dsl.run
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should generate cloudformation template" do
|
92
|
-
raw = IO.read("#{@project}/output/prod-api-app.json")
|
93
|
-
json = JSON.load(raw)
|
94
|
-
expect(json['Description']).to eq "Api Stack"
|
95
|
-
expect(json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64']).to eq 'ami-123'
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should make trailing options pass to the partial helper available as instance variables" do
|
99
|
-
raw = IO.read("#{@project}/output/prod-api-app.json")
|
100
|
-
json = JSON.load(raw)
|
101
|
-
expect(json['Resources']['HostRecord']['Properties']['Comment']).to eq 'DNS name for mydomain.com'
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should generate user data with variables" do
|
105
|
-
raw = IO.read("#{@project}/output/prod-api-redis.json")
|
106
|
-
json = JSON.load(raw)
|
107
|
-
expect(json['Description']).to eq "Api redis"
|
108
|
-
user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
|
109
|
-
expect(user_data).to include("VARTEST=foo\n")
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should include multiple user_data scripts" do
|
113
|
-
raw = IO.read("#{@project}/output/prod-api-redis.json")
|
114
|
-
json = JSON.load(raw)
|
115
|
-
expect(json['Description']).to eq "Api redis"
|
116
|
-
user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
|
117
|
-
expect(user_data).to include("DB2=test\n")
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should generate db template" do
|
121
|
-
raw = IO.read("#{@project}/output/prod-api-redis.json")
|
122
|
-
json = JSON.load(raw)
|
123
|
-
expect(json['Description']).to eq "Api redis"
|
124
|
-
user_data = json['Resources']['server']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
|
125
|
-
expect(user_data).to include({"Ref" => "AWS::StackName"})
|
126
|
-
expect(user_data).to include({"Ref" => "WaitHandle"})
|
127
|
-
expect(user_data).to include({
|
128
|
-
"Fn::FindInMap" => [
|
129
|
-
"EnvironmentMapping",
|
130
|
-
"HostnamePrefix",
|
131
|
-
{"Ref" => "Environment"}
|
132
|
-
]
|
133
|
-
})
|
134
|
-
expect(user_data).to include({
|
135
|
-
"Fn::FindInMap" => [
|
136
|
-
"MapName",
|
137
|
-
"TopLevelKey",
|
138
|
-
"SecondLevelKey"
|
139
|
-
]
|
140
|
-
})
|
141
|
-
expect(user_data).to include({"Ref" => "DRINK"})
|
142
|
-
|
143
|
-
expect(user_data).to include({"Fn::Base64" => "value to encode"})
|
144
|
-
expect(user_data).to include({"Fn::GetAtt" => ["server", "PublicDnsName"]})
|
145
|
-
expect(user_data).to include({"Fn::GetAZs" => "AWS::Region"})
|
146
|
-
expect(user_data).to include({"Fn::Join" => [ ':', ['a','b','c']]})
|
147
|
-
expect(user_data).to include({"Fn::Select" => [ '1', ['a','b','c']]})
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should transform bash script to CF template user_data" do
|
151
|
-
block = Proc.new { }
|
152
|
-
template = Lono::Template.new("foo", block)
|
153
|
-
|
154
|
-
line = 'echo {"Ref"=>"AWS::StackName"} > /tmp/stack_name ; {"Ref"=>"Ami"}'
|
155
|
-
data = template.transform(line)
|
156
|
-
expect(data).to eq ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
|
157
|
-
|
158
|
-
line = 'echo {"Ref"=>"AWS::StackName"} > /tmp/stack_name'
|
159
|
-
data = template.transform(line)
|
160
|
-
expect(data).to eq ["echo ", {"Ref"=>"AWS::StackName"}, " > /tmp/stack_name\n"]
|
161
|
-
|
162
|
-
line = 'echo {"Fn::FindInMap" => [ "A", "B", {"Ref"=>"AWS::StackName"} ]}'
|
163
|
-
data = template.transform(line)
|
164
|
-
expect(data).to eq ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, "\n"]
|
165
|
-
|
166
|
-
line = 'echo {"Fn::FindInMap" => [ "A", "B", {"Ref"=>"AWS::StackName"} ]} > /tmp/stack_name ; {"Ref"=>"Ami"}'
|
167
|
-
data = template.transform(line)
|
168
|
-
expect(data).to eq ["echo ", {"Fn::FindInMap" => ["A", "B", {"Ref"=>"AWS::StackName"}]}, " > /tmp/stack_name ; ", {"Ref"=>"Ami"}, "\n"]
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should not transform user_data ruby scripts" do
|
172
|
-
raw = IO.read("#{@project}/output/prod-api-worker.json")
|
173
|
-
json = JSON.load(raw)
|
174
|
-
user_data = json['Resources']['LaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'][1]
|
175
|
-
expect(user_data).to include(%Q|ec2.tags.create(ec2.instances[my_instance_id], "Name", {value: Facter.hostname})\n|)
|
176
|
-
expect(user_data).to include(%Q{find_all{ |record_set| record_set[:name] == record_name }\n})
|
177
|
-
end
|
178
|
-
|
179
|
-
it "should create parent folders for parent/db-stack.json" do
|
180
|
-
directory_created = File.exist?("#{@project}/output/parent")
|
181
|
-
expect(directory_created).to be true
|
182
|
-
end
|
183
|
-
|
184
|
-
it "task should generate CloudFormation templates" do
|
185
|
-
raw = IO.read("#{@project}/output/prod-api-app.json")
|
186
|
-
json = JSON.load(raw)
|
187
|
-
expect(json['Description']).to eq "Api Stack"
|
188
|
-
expect(json['Mappings']['AWSRegionArch2AMI']['us-east-1']['64']).to eq 'ami-123'
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
82
|
describe "cli specs" do
|
193
83
|
it "should generate templates" do
|
194
|
-
out = execute("./bin/lono generate -c --project-root #{@
|
84
|
+
out = execute("./bin/lono generate -c --project-root #{@project_root}")
|
195
85
|
expect(out).to match /Generating CloudFormation templates/
|
196
86
|
end
|
197
87
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: byebug
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description: Lono is a CloudFormation Template ruby generator. Lono generates CloudFormation
|
168
182
|
templates based on ERB templates.
|
169
183
|
email:
|
@@ -193,20 +207,31 @@ files:
|
|
193
207
|
- lib/lono/new.rb
|
194
208
|
- lib/lono/template.rb
|
195
209
|
- lib/lono/version.rb
|
196
|
-
- lib/
|
197
|
-
- lib/
|
198
|
-
- lib/
|
199
|
-
- lib/
|
200
|
-
- lib/
|
201
|
-
- lib/
|
202
|
-
- lib/
|
203
|
-
- lib/
|
204
|
-
- lib/
|
205
|
-
- lib/
|
206
|
-
- lib/
|
207
|
-
- lib/
|
210
|
+
- lib/starter_project_json/Gemfile
|
211
|
+
- lib/starter_project_json/Guardfile
|
212
|
+
- lib/starter_project_json/config/lono.rb
|
213
|
+
- lib/starter_project_json/config/lono/api.rb
|
214
|
+
- lib/starter_project_json/templates/db.json.erb
|
215
|
+
- lib/starter_project_json/templates/partial/host_record.json.erb
|
216
|
+
- lib/starter_project_json/templates/partial/server.json.erb
|
217
|
+
- lib/starter_project_json/templates/user_data/app.sh.erb
|
218
|
+
- lib/starter_project_json/templates/user_data/db.sh.erb
|
219
|
+
- lib/starter_project_json/templates/user_data/db2.sh.erb
|
220
|
+
- lib/starter_project_json/templates/user_data/ruby_script.rb.erb
|
221
|
+
- lib/starter_project_json/templates/web.json.erb
|
222
|
+
- lib/starter_project_yaml/Gemfile
|
223
|
+
- lib/starter_project_yaml/Guardfile
|
224
|
+
- lib/starter_project_yaml/config/lono.rb
|
225
|
+
- lib/starter_project_yaml/config/lono/api.rb
|
226
|
+
- lib/starter_project_yaml/templates/db.yml.erb
|
227
|
+
- lib/starter_project_yaml/templates/partial/host_record.yml.erb
|
228
|
+
- lib/starter_project_yaml/templates/partial/server.yml.erb
|
229
|
+
- lib/starter_project_yaml/templates/partial/user_data/bootstrap.sh.erb
|
230
|
+
- lib/starter_project_yaml/templates/web.yml.erb
|
208
231
|
- lono.gemspec
|
209
232
|
- spec/fixtures/cfn.json
|
233
|
+
- spec/lib/lono/dsl_spec.rb
|
234
|
+
- spec/lib/lono/new_spec.rb
|
210
235
|
- spec/lib/lono_spec.rb
|
211
236
|
- spec/spec_helper.rb
|
212
237
|
homepage: http://github.com/tongueroo/lono
|
@@ -229,12 +254,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
254
|
version: '0'
|
230
255
|
requirements: []
|
231
256
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
257
|
+
rubygems_version: 2.5.2
|
233
258
|
signing_key:
|
234
259
|
specification_version: 4
|
235
260
|
summary: Lono is a CloudFormation Template ruby generator. Lono generates CloudFormation
|
236
261
|
templates based on ERB templates.
|
237
262
|
test_files:
|
238
263
|
- spec/fixtures/cfn.json
|
264
|
+
- spec/lib/lono/dsl_spec.rb
|
265
|
+
- spec/lib/lono/new_spec.rb
|
239
266
|
- spec/lib/lono_spec.rb
|
240
267
|
- spec/spec_helper.rb
|