kumo_keisei 3.1.1 → 3.2.0
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/VERSION +1 -1
- data/lib/kumo_keisei/stack.rb +7 -4
- data/spec/lib/kumo_keisei/stack_spec.rb +46 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6d8ec619b69634348ca0d40ee8be1c4a1b236b2
|
4
|
+
data.tar.gz: aa6f7aa6c067191256ba89fa53b4ed52bb6ba7c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51d5efe78c8e8e45fc83a7cf434f3df9e74e63b8b657215a981104f14e3825905fa189e9da75947760d63b9848772ce81ac7394671bca3ad2e2b4e660c98543a
|
7
|
+
data.tar.gz: 67eb98dc2278360e47d05e1caaae9e91be7a4820f4faf54f108f04a13733e3163f4566ec59625fe5f4604da752ad85aacf234a08683c8fb9bc1cfb12425f5479
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/lib/kumo_keisei/stack.rb
CHANGED
@@ -29,10 +29,10 @@ module KumoKeisei
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def initialize(app_name, environment_name, options = { confirmation_timeout: 30, waiter_delay: 20, waiter_attempts: 90 })
|
32
|
-
type = options
|
32
|
+
type = options.fetch(:type, 'nodes')
|
33
33
|
@env_name = environment_name
|
34
34
|
@app_name = app_name
|
35
|
-
@stack_name =
|
35
|
+
@stack_name = "#{app_name}-#{type}-#{ environment_name }"
|
36
36
|
@confirmation_timeout = options[:confirmation_timeout]
|
37
37
|
@waiter_delay = options[:waiter_delay]
|
38
38
|
@waiter_attempts = options[:waiter_attempts]
|
@@ -85,6 +85,10 @@ module KumoKeisei
|
|
85
85
|
environment_config(stack_config).config
|
86
86
|
end
|
87
87
|
|
88
|
+
def params_template_path(stack_config)
|
89
|
+
stack_config.has_key?(:template_path) ? File.absolute_path(File.join(File.dirname(stack_config[:template_path]), "#{File.basename(stack_config[:template_path], '.*')}.yml.erb")) : nil
|
90
|
+
end
|
91
|
+
|
88
92
|
private
|
89
93
|
|
90
94
|
def transform_logical_resource_id(id)
|
@@ -162,8 +166,7 @@ module KumoKeisei
|
|
162
166
|
end
|
163
167
|
|
164
168
|
def environment_config(stack_config)
|
165
|
-
|
166
|
-
EnvironmentConfig.new(stack_config.merge(params_template_file_path: params_template_path))
|
169
|
+
EnvironmentConfig.new(stack_config.merge(params_template_file_path: params_template_path(stack_config)))
|
167
170
|
end
|
168
171
|
|
169
172
|
def stack_events_url
|
@@ -10,9 +10,10 @@ describe KumoKeisei::Stack do
|
|
10
10
|
|
11
11
|
let(:app_name) { "my-stack" }
|
12
12
|
let(:environment_name) { 'non-production' }
|
13
|
-
let(:stack_name) { "#{app_name}-#{environment_name}" }
|
14
|
-
let(:
|
15
|
-
let(:
|
13
|
+
let(:stack_name) { "#{app_name}-nodes-#{environment_name}" }
|
14
|
+
let(:stack_template_name) { "#{app_name}-#{environment_name}" }
|
15
|
+
let(:stack_cfntemplate_filename) { "#{stack_template_name}.json" }
|
16
|
+
let(:stack_cfnparams_filename) { "#{stack_template_name}.yml.erb" }
|
16
17
|
let(:cloudformation) { instance_double(Aws::CloudFormation::Client) }
|
17
18
|
let(:happy_stack_status) { "CREATE_COMPLETE" }
|
18
19
|
let(:cf_stack) { stack_result_list_with_status(happy_stack_status, stack_name) }
|
@@ -34,7 +35,7 @@ describe KumoKeisei::Stack do
|
|
34
35
|
let(:stack_config) {
|
35
36
|
{
|
36
37
|
config_path: 'config-path',
|
37
|
-
template_path:
|
38
|
+
template_path: stack_cfntemplate_filename,
|
38
39
|
injected_config: { 'VpcId' => 'vpc-id' },
|
39
40
|
env_name: 'non-production'
|
40
41
|
}
|
@@ -49,9 +50,10 @@ describe KumoKeisei::Stack do
|
|
49
50
|
allow(Aws::CloudFormation::Client).to receive(:new).and_return(cloudformation)
|
50
51
|
allow(cloudformation).to receive(:describe_stacks).with({stack_name: stack_name}).and_return(cf_stack)
|
51
52
|
allow(KumoKeisei::ParameterBuilder).to receive(:new).and_return(parameter_builder)
|
52
|
-
allow(File).to receive(:read).with(
|
53
|
-
allow(KumoKeisei::EnvironmentConfig).to receive(:new).with(stack_config.merge(params_template_file_path: "
|
54
|
-
allow(File).to receive(:absolute_path).and_return("#{app_name}.yml.erb")
|
53
|
+
allow(File).to receive(:read).with(stack_cfntemplate_filename).and_return(stack_template_body)
|
54
|
+
allow(KumoKeisei::EnvironmentConfig).to receive(:new).with(stack_config.merge(params_template_file_path: "/#{stack_cfnparams_filename}")).and_return(double(:environment_config, cf_params: {}))
|
55
|
+
# allow(File).to receive(:absolute_path).and_return("#{app_name}.yml.erb")
|
56
|
+
Dir.chdir('/')
|
55
57
|
end
|
56
58
|
|
57
59
|
describe "#destroy!" do
|
@@ -271,8 +273,8 @@ describe KumoKeisei::Stack do
|
|
271
273
|
end
|
272
274
|
|
273
275
|
describe "#type" do
|
274
|
-
it "
|
275
|
-
expect(subject.stack_name).to eq("#{app_name}-#{environment_name}")
|
276
|
+
it "presumes stacks are of type node if the type is not set" do
|
277
|
+
expect(subject.stack_name).to eq("#{app_name}-nodes-#{environment_name}")
|
276
278
|
end
|
277
279
|
|
278
280
|
it "embeds the type into the name of the stack if set" do
|
@@ -283,11 +285,8 @@ describe KumoKeisei::Stack do
|
|
283
285
|
|
284
286
|
describe "#config" do
|
285
287
|
context "when passed a config_path and params_template_file_path" do
|
286
|
-
before do
|
287
|
-
allow(KumoKeisei::EnvironmentConfig).to receive(:new).with(stack_config.merge(params_template_file_path: "#{app_name}.yml.erb")).and_return(double(:environment_config, cf_params: {}, config: { :foo=> 'bar', :baz=> 'qux' }))
|
288
|
-
end
|
289
|
-
|
290
288
|
it "will return the results of the nested KumoKeisei::EnvironmentConfig.config" do
|
289
|
+
expect(KumoKeisei::EnvironmentConfig).to receive(:new).with(stack_config.merge(params_template_file_path: "/#{stack_template_name}.yml.erb")).and_return(double(:environment_config, cf_params: {}, config: { :foo=> 'bar', :baz=> 'qux' }))
|
291
290
|
expect(subject.config(stack_config)).to eq({:foo=> 'bar', :baz=>'qux'})
|
292
291
|
end
|
293
292
|
end
|
@@ -300,11 +299,8 @@ describe KumoKeisei::Stack do
|
|
300
299
|
}
|
301
300
|
}
|
302
301
|
|
303
|
-
before do
|
304
|
-
allow(KumoKeisei::EnvironmentConfig).to receive(:new).with(stack_config.merge(params_template_file_path: nil)).and_return(double(:environment_config, cf_params: {}, config: { :foo=> 'bar', :baz=> 'qux' }))
|
305
|
-
end
|
306
|
-
|
307
302
|
it "will return the results of the nested KumoKeisei::EnvironmentConfig.config" do
|
303
|
+
expect(KumoKeisei::EnvironmentConfig).to receive(:new).with(stack_config.merge(params_template_file_path: nil)).and_return(double(:environment_config, cf_params: {}, config: { :foo=> 'bar', :baz=> 'qux' }))
|
308
304
|
expect(subject.config(stack_config)).to eq({:foo=> 'bar', :baz=>'qux'})
|
309
305
|
end
|
310
306
|
end
|
@@ -322,4 +318,37 @@ describe KumoKeisei::Stack do
|
|
322
318
|
end
|
323
319
|
end
|
324
320
|
|
321
|
+
describe "#params_template_path" do
|
322
|
+
context "when looking for the parameter template file" do
|
323
|
+
CFN_STACK_TEMPLATE_TO_PARAMATER_TEMPLATE = {
|
324
|
+
'/foo/app.json' => '/foo/app.yml.erb',
|
325
|
+
'/foo/rds.json' => '/foo/rds.yml.erb'
|
326
|
+
}
|
327
|
+
|
328
|
+
CFN_STACK_TEMPLATE_TO_PARAMATER_TEMPLATE.each_pair do |cfn_template, parameter_template|
|
329
|
+
context "given #{cfn_template}" do
|
330
|
+
let(:stack_cfntemplate_filename) { "#{cfn_template}" }
|
331
|
+
it "uses a matching file in the form of #{parameter_template}" do
|
332
|
+
expect(subject.params_template_path(stack_config)).to eq(File.join(Dir.pwd, parameter_template))
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
context "when the parameter template file has not been passed in" do
|
339
|
+
let(:stack_config) {
|
340
|
+
{
|
341
|
+
config_path: 'config-path',
|
342
|
+
injected_config: { 'VpcId' => 'vpc-id' },
|
343
|
+
env_name: 'non-production'
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
it "will return nil" do
|
348
|
+
expect(subject.params_template_path(stack_config)).to be_nil
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|
353
|
+
|
325
354
|
end
|