stack_master 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -7
- data/Rakefile +2 -0
- data/bin/stack_master +2 -1
- data/features/apply.feature +63 -26
- data/features/delete.feature +5 -18
- data/features/diff.feature +6 -18
- data/features/events.feature +1 -5
- data/features/outputs.feature +1 -5
- data/features/region_aliases.feature +0 -4
- data/features/resources.feature +1 -4
- data/features/stack_defaults.feature +1 -7
- data/features/status.feature +2 -8
- data/features/step_definitions/stack_steps.rb +16 -0
- data/features/support/env.rb +1 -0
- data/features/validate.feature +46 -0
- data/lib/stack_master.rb +21 -0
- data/lib/stack_master/aws_driver/cloud_formation.rb +20 -1
- data/lib/stack_master/cli.rb +54 -27
- data/lib/stack_master/command.rb +9 -1
- data/lib/stack_master/commands/apply.rb +2 -0
- data/lib/stack_master/commands/list_stacks.rb +2 -0
- data/lib/stack_master/commands/outputs.rb +2 -1
- data/lib/stack_master/commands/status.rb +2 -0
- data/lib/stack_master/commands/terminal_helper.rb +15 -0
- data/lib/stack_master/commands/validate.rb +1 -1
- data/lib/stack_master/config.rb +9 -5
- data/lib/stack_master/parameter_resolver.rb +11 -5
- data/lib/stack_master/parameter_resolvers/latest_ami_by_tags.rb +3 -1
- data/lib/stack_master/parameter_resolvers/secret.rb +3 -1
- data/lib/stack_master/parameter_resolvers/security_group.rb +4 -2
- data/lib/stack_master/parameter_resolvers/sns_topic_name.rb +3 -1
- data/lib/stack_master/parameter_resolvers/stack_output.rb +3 -1
- data/lib/stack_master/prompter.rb +10 -3
- data/lib/stack_master/resolver_array.rb +35 -0
- data/lib/stack_master/testing.rb +1 -0
- data/lib/stack_master/validator.rb +8 -4
- data/lib/stack_master/version.rb +1 -1
- data/spec/fixtures/stack_master.yml +4 -1
- data/spec/stack_master/command_spec.rb +28 -0
- data/spec/stack_master/commands/apply_spec.rb +12 -2
- data/spec/stack_master/commands/status_spec.rb +25 -2
- data/spec/stack_master/commands/validate_spec.rb +1 -1
- data/spec/stack_master/config_spec.rb +42 -8
- data/spec/stack_master/parameter_resolver_spec.rb +6 -2
- data/spec/stack_master/parameter_resolvers/security_group_spec.rb +5 -3
- data/spec/stack_master/parameter_resolvers/security_groups_spec.rb +32 -0
- data/spec/stack_master/prompter_spec.rb +23 -0
- data/spec/stack_master/resolver_array_spec.rb +42 -0
- data/spec/stack_master/validator_spec.rb +2 -2
- metadata +15 -3
@@ -30,16 +30,20 @@ RSpec.describe StackMaster::ParameterResolver do
|
|
30
30
|
expect(resolve(param1: 'value1')).to eq(param1: 'value1')
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'returns integers as strings' do
|
34
|
+
expect(resolve(param1: 2)).to eq(param1: '2')
|
35
|
+
end
|
36
|
+
|
33
37
|
it 'it throws an error when the hash contains more than one key' do
|
34
38
|
expect {
|
35
39
|
resolve(param: { nested1: 'value1', nested2: 'value2' })
|
36
40
|
}.to raise_error(StackMaster::ParameterResolver::InvalidParameter)
|
37
41
|
end
|
38
42
|
|
39
|
-
it '
|
43
|
+
it "doesn't throw an error when given an array" do
|
40
44
|
expect {
|
41
45
|
resolve(param: [1, 2])
|
42
|
-
}.
|
46
|
+
}.to_not raise_error
|
43
47
|
end
|
44
48
|
|
45
49
|
context 'when given a proper resolve hash' do
|
@@ -7,11 +7,13 @@ RSpec.describe StackMaster::ParameterResolvers::SecurityGroup do
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
allow(StackMaster::SecurityGroupFinder).to receive(:new).with('us-east-1').and_return finder
|
10
|
-
|
10
|
+
expect(finder).to receive(:find).once.with(sg_name).and_return sg_id
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
context 'when given a single SG name' do
|
14
|
+
it "resolves the security group" do
|
15
|
+
expect(resolver.resolve(sg_name)).to eq sg_id
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
RSpec.describe StackMaster::ParameterResolvers::SecurityGroups do
|
2
|
+
describe "#resolve" do
|
3
|
+
subject(:resolver) { described_class.new(nil, double(region: 'us-east-1')) }
|
4
|
+
let(:finder) { instance_double(StackMaster::SecurityGroupFinder) }
|
5
|
+
let(:sg_id) { 'sg-id' }
|
6
|
+
let(:sg_name) { 'sg-name' }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(StackMaster::SecurityGroupFinder).to receive(:new).with('us-east-1').and_return finder
|
10
|
+
expect(finder).to receive(:find).once.with(sg_name).and_return sg_id
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when given a single SG name' do
|
14
|
+
it "resolves the security group" do
|
15
|
+
expect(resolver.resolve(sg_name)).to eq [sg_id]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when given a an array of SG names' do
|
20
|
+
let(:sg_id2) { 'sg-id2' }
|
21
|
+
let(:sg_name2) { 'sg-name2' }
|
22
|
+
|
23
|
+
before do
|
24
|
+
expect(finder).to receive(:find).once.with(sg_name2).and_return sg_id2
|
25
|
+
end
|
26
|
+
|
27
|
+
it "resolves the security groups" do
|
28
|
+
expect(resolver.resolve([sg_name, sg_name2])).to eq [sg_id, sg_id2]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
RSpec.describe StackMaster::Prompter do
|
2
|
+
include StackMaster::Prompter
|
3
|
+
|
4
|
+
context 'when STDIN is not a TTY' do
|
5
|
+
before do
|
6
|
+
allow(StackMaster.stdin).to receive(:tty?).and_return(false)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'defaults to no and outputs info about -y' do
|
10
|
+
expect { ask?('blah') }.to output(/To force yes use -y/).to_stdout
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when STDOUT is not a TTY' do
|
15
|
+
before do
|
16
|
+
allow(StackMaster.stdout).to receive(:tty?).and_return(false)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'defaults to no and outputs info about -y' do
|
20
|
+
expect { ask?('blah') }.to output(/To force yes use -y/).to_stdout
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'stack_master/resolver_array'
|
2
|
+
|
3
|
+
RSpec.shared_examples_for 'a resolver' do
|
4
|
+
it 'should create a TestResolvers class' do
|
5
|
+
expect(array_resolver_class).to be_a Class
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have TestResolver as a resolver class' do
|
9
|
+
expect(array_resolver_instance).to respond_to :resolver_class
|
10
|
+
expect(array_resolver_instance.resolver_class).to be TestResolver
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.describe 'StackMaster::ParameterResolvers::Resolver' do
|
15
|
+
let(:array_resolver_instance) { array_resolver_class.new(nil, nil) }
|
16
|
+
|
17
|
+
describe '.array_resolver' do
|
18
|
+
context 'when using a default name' do
|
19
|
+
before do
|
20
|
+
class TestResolver < StackMaster::ParameterResolvers::Resolver
|
21
|
+
array_resolver
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:array_resolver_class) { StackMaster::ParameterResolvers::TestResolvers }
|
26
|
+
|
27
|
+
it_behaves_like 'a resolver'
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when using a specific name' do
|
31
|
+
before do
|
32
|
+
class TestResolver < StackMaster::ParameterResolvers::Resolver
|
33
|
+
array_resolver class_name: 'SpecificResolver'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:array_resolver_class) { StackMaster::ParameterResolvers::SpecificResolver }
|
38
|
+
|
39
|
+
it_behaves_like 'a resolver'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -21,7 +21,7 @@ RSpec.describe StackMaster::Validator do
|
|
21
21
|
cf.stub_responses(:validate_template, nil)
|
22
22
|
end
|
23
23
|
it "tells the user everything will be fine" do
|
24
|
-
expect { validator.perform }.to output(/
|
24
|
+
expect { validator.perform }.to output(/myapp_vpc: valid/).to_stdout
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -30,7 +30,7 @@ RSpec.describe StackMaster::Validator do
|
|
30
30
|
cf.stub_responses(:validate_template, Aws::CloudFormation::Errors::ValidationError.new('a', 'Problem'))
|
31
31
|
end
|
32
32
|
it "informs the user of their stupdity" do
|
33
|
-
expect { validator.perform }.to output(/
|
33
|
+
expect { validator.perform }.to output(/myapp_vpc: invalid/).to_stdout
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stack_master
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Hodgkiss
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -299,6 +299,7 @@ files:
|
|
299
299
|
- features/status.feature
|
300
300
|
- features/step_definitions/stack_steps.rb
|
301
301
|
- features/support/env.rb
|
302
|
+
- features/validate.feature
|
302
303
|
- lib/stack_master.rb
|
303
304
|
- lib/stack_master/aws_driver/cloud_formation.rb
|
304
305
|
- lib/stack_master/cli.rb
|
@@ -312,6 +313,7 @@ files:
|
|
312
313
|
- lib/stack_master/commands/outputs.rb
|
313
314
|
- lib/stack_master/commands/resources.rb
|
314
315
|
- lib/stack_master/commands/status.rb
|
316
|
+
- lib/stack_master/commands/terminal_helper.rb
|
315
317
|
- lib/stack_master/commands/validate.rb
|
316
318
|
- lib/stack_master/config.rb
|
317
319
|
- lib/stack_master/ctrl_c.rb
|
@@ -323,6 +325,7 @@ files:
|
|
323
325
|
- lib/stack_master/parameter_resolvers/sns_topic_name.rb
|
324
326
|
- lib/stack_master/parameter_resolvers/stack_output.rb
|
325
327
|
- lib/stack_master/prompter.rb
|
328
|
+
- lib/stack_master/resolver_array.rb
|
326
329
|
- lib/stack_master/security_group_finder.rb
|
327
330
|
- lib/stack_master/sns_topic_finder.rb
|
328
331
|
- lib/stack_master/stack.rb
|
@@ -346,6 +349,7 @@ files:
|
|
346
349
|
- spec/fixtures/stack_master.yml
|
347
350
|
- spec/fixtures/templates/myapp_vpc.json
|
348
351
|
- spec/spec_helper.rb
|
352
|
+
- spec/stack_master/command_spec.rb
|
349
353
|
- spec/stack_master/commands/apply_spec.rb
|
350
354
|
- spec/stack_master/commands/delete_spec.rb
|
351
355
|
- spec/stack_master/commands/init_spec.rb
|
@@ -357,8 +361,11 @@ files:
|
|
357
361
|
- spec/stack_master/parameter_resolvers/latest_ami_by_tag_spec.rb
|
358
362
|
- spec/stack_master/parameter_resolvers/secret_spec.rb
|
359
363
|
- spec/stack_master/parameter_resolvers/security_group_spec.rb
|
364
|
+
- spec/stack_master/parameter_resolvers/security_groups_spec.rb
|
360
365
|
- spec/stack_master/parameter_resolvers/sns_topic_name_spec.rb
|
361
366
|
- spec/stack_master/parameter_resolvers/stack_output_spec.rb
|
367
|
+
- spec/stack_master/prompter_spec.rb
|
368
|
+
- spec/stack_master/resolver_array_spec.rb
|
362
369
|
- spec/stack_master/security_group_finder_spec.rb
|
363
370
|
- spec/stack_master/sns_topic_finder_spec.rb
|
364
371
|
- spec/stack_master/stack_definition_spec.rb
|
@@ -396,7 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
396
403
|
version: '0'
|
397
404
|
requirements: []
|
398
405
|
rubyforge_project:
|
399
|
-
rubygems_version: 2.
|
406
|
+
rubygems_version: 2.4.5.1
|
400
407
|
signing_key:
|
401
408
|
specification_version: 4
|
402
409
|
summary: StackMaster is a sure-footed way of creating, updating and keeping track
|
@@ -414,10 +421,12 @@ test_files:
|
|
414
421
|
- features/status.feature
|
415
422
|
- features/step_definitions/stack_steps.rb
|
416
423
|
- features/support/env.rb
|
424
|
+
- features/validate.feature
|
417
425
|
- spec/fixtures/parameters/myapp_vpc.yml
|
418
426
|
- spec/fixtures/stack_master.yml
|
419
427
|
- spec/fixtures/templates/myapp_vpc.json
|
420
428
|
- spec/spec_helper.rb
|
429
|
+
- spec/stack_master/command_spec.rb
|
421
430
|
- spec/stack_master/commands/apply_spec.rb
|
422
431
|
- spec/stack_master/commands/delete_spec.rb
|
423
432
|
- spec/stack_master/commands/init_spec.rb
|
@@ -429,8 +438,11 @@ test_files:
|
|
429
438
|
- spec/stack_master/parameter_resolvers/latest_ami_by_tag_spec.rb
|
430
439
|
- spec/stack_master/parameter_resolvers/secret_spec.rb
|
431
440
|
- spec/stack_master/parameter_resolvers/security_group_spec.rb
|
441
|
+
- spec/stack_master/parameter_resolvers/security_groups_spec.rb
|
432
442
|
- spec/stack_master/parameter_resolvers/sns_topic_name_spec.rb
|
433
443
|
- spec/stack_master/parameter_resolvers/stack_output_spec.rb
|
444
|
+
- spec/stack_master/prompter_spec.rb
|
445
|
+
- spec/stack_master/resolver_array_spec.rb
|
434
446
|
- spec/stack_master/security_group_finder_spec.rb
|
435
447
|
- spec/stack_master/sns_topic_finder_spec.rb
|
436
448
|
- spec/stack_master/stack_definition_spec.rb
|