stack_master 1.2.1 → 1.3.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 +24 -0
- data/lib/stack_master/stack.rb +1 -1
- data/lib/stack_master/template_compilers/sparkle_formation.rb +28 -6
- data/lib/stack_master/version.rb +1 -1
- data/spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/my_sparkle_pack.rb +1 -0
- data/spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/sparkleformation/dynamics/my_dynamic.rb +5 -0
- data/spec/fixtures/sparkle_pack_integration/templates/dynamics/local_dynamic.rb +5 -0
- data/spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic.rb +3 -0
- data/spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic_from_pack.rb +3 -0
- data/spec/stack_master/template_compilers/sparkle_formation_spec.rb +35 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80f3544c2f5a4920fcc6bfb3ff09a524549f028cba7a6736b0e761560599d73
|
4
|
+
data.tar.gz: 2bee13731638f892921863c688c88e59fd4213e906c73afc1cc2434b3b36b4f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8b64ef00d94df9456194077d70386143a9722ffd52b04177c38eacd76805bd377a1116f5c29e70d346b730a758c57628404f4ad416210a4d224fc2590e72719
|
7
|
+
data.tar.gz: fb8a380e0ac314af64e62e5395ec43a8550e1590080aa698ff150cc4ee6c90b508e521a1a9086e8837e4c3f000cf0d1a9d01e2e582c4a8d365077e8e38fa8b0d
|
data/README.md
CHANGED
@@ -467,6 +467,30 @@ stacks:
|
|
467
467
|
template: my-stack.rb
|
468
468
|
```
|
469
469
|
|
470
|
+
### Loading SparklePacks
|
471
|
+
|
472
|
+
[SparklePacks](http://www.sparkleformation.io/docs/sparkle_formation/sparkle-packs.html) can be pre-loaded using compiler options. This requires the name of a rubygem to `require` followed by the name of the SparklePack, which is usually the same name as the Gem.
|
473
|
+
|
474
|
+
```yaml
|
475
|
+
stacks:
|
476
|
+
us-east-1
|
477
|
+
my-stack:
|
478
|
+
template: my-stack-with-dynamic.rb
|
479
|
+
compiler_options:
|
480
|
+
sparkle_packs:
|
481
|
+
- vpc-sparkle-pack
|
482
|
+
```
|
483
|
+
|
484
|
+
The template can then simply load a dynamic from the sparkle pack like so:
|
485
|
+
|
486
|
+
```ruby
|
487
|
+
SparkleFormation.new(:my_stack_with_dynamic) do
|
488
|
+
dynamic!(:sparkle_pack_dynamic)
|
489
|
+
end
|
490
|
+
```
|
491
|
+
|
492
|
+
Note though that if a dynamic with the same name exists in your `templates/dynamics/` directory it will get loaded since it has higher precedence.
|
493
|
+
|
470
494
|
## Commands
|
471
495
|
|
472
496
|
```bash
|
data/lib/stack_master/stack.rb
CHANGED
@@ -65,7 +65,7 @@ module StackMaster
|
|
65
65
|
parameter_hash = ParameterLoader.load(stack_definition.parameter_files)
|
66
66
|
template_parameters = ParameterResolver.resolve(config, stack_definition, parameter_hash[:template_parameters])
|
67
67
|
compile_time_parameters = ParameterResolver.resolve(config, stack_definition, parameter_hash[:compile_time_parameters])
|
68
|
-
template_body = TemplateCompiler.compile(config, stack_definition.template_file_path, compile_time_parameters,stack_definition.compiler_options)
|
68
|
+
template_body = TemplateCompiler.compile(config, stack_definition.template_file_path, compile_time_parameters, stack_definition.compiler_options)
|
69
69
|
template_format = TemplateUtils.identify_template_format(template_body)
|
70
70
|
stack_policy_body = if stack_definition.stack_policy_file_path
|
71
71
|
File.read(stack_definition.stack_policy_file_path)
|
@@ -13,12 +13,7 @@ module StackMaster::TemplateCompilers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.compile(template_file_path, compile_time_parameters, compiler_options = {})
|
16
|
-
|
17
|
-
::SparkleFormation.sparkle_path = File.expand_path(compiler_options['sparkle_path'])
|
18
|
-
else
|
19
|
-
::SparkleFormation.sparkle_path = File.dirname(template_file_path)
|
20
|
-
end
|
21
|
-
sparkle_template = ::SparkleFormation.compile(template_file_path, :sparkle)
|
16
|
+
sparkle_template = compile_sparkle_template(template_file_path, compiler_options)
|
22
17
|
definitions = sparkle_template.parameters
|
23
18
|
validate_definitions(definitions)
|
24
19
|
validate_parameters(definitions, compile_time_parameters)
|
@@ -32,6 +27,33 @@ module StackMaster::TemplateCompilers
|
|
32
27
|
|
33
28
|
private
|
34
29
|
|
30
|
+
def self.compile_sparkle_template(template_file_path, compiler_options)
|
31
|
+
sparkle_path = compiler_options['sparkle_path'] ?
|
32
|
+
File.expand_path(compiler_options['sparkle_path']) : File.dirname(template_file_path)
|
33
|
+
|
34
|
+
collection = ::SparkleFormation::SparkleCollection.new
|
35
|
+
root_pack = ::SparkleFormation::Sparkle.new(
|
36
|
+
:root => sparkle_path,
|
37
|
+
)
|
38
|
+
collection.set_root(root_pack)
|
39
|
+
if compiler_options['sparkle_packs']
|
40
|
+
compiler_options['sparkle_packs'].each do |pack_name|
|
41
|
+
require pack_name
|
42
|
+
pack = ::SparkleFormation::SparklePack.new(:name => pack_name)
|
43
|
+
collection.add_sparkle(pack)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
sparkle_template = compile_template_with_sparkle_path(template_file_path, sparkle_path)
|
48
|
+
sparkle_template.sparkle.apply(collection)
|
49
|
+
sparkle_template
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.compile_template_with_sparkle_path(template_path, sparkle_path)
|
53
|
+
::SparkleFormation.sparkle_path = sparkle_path
|
54
|
+
::SparkleFormation.compile(template_path, :sparkle)
|
55
|
+
end
|
56
|
+
|
35
57
|
def self.validate_definitions(definitions)
|
36
58
|
CompileTime::DefinitionsValidator.new(definitions).validate
|
37
59
|
end
|
data/lib/stack_master/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
::SparkleFormation::SparklePack.register!
|
@@ -15,13 +15,20 @@ RSpec.describe StackMaster::TemplateCompilers::SparkleFormation do
|
|
15
15
|
let(:parameters_validator) { instance_double(StackMaster::SparkleFormation::CompileTime::ParametersValidator) }
|
16
16
|
let(:state_builder) { instance_double(StackMaster::SparkleFormation::CompileTime::StateBuilder) }
|
17
17
|
|
18
|
+
let(:sparkle_double) { instance_double(::SparkleFormation::SparkleCollection) }
|
19
|
+
|
18
20
|
before do
|
19
21
|
allow(::SparkleFormation).to receive(:compile).with(template_file_path, :sparkle).and_return(sparkle_template)
|
22
|
+
allow(::SparkleFormation::Sparkle).to receive(:new)
|
20
23
|
allow(StackMaster::SparkleFormation::CompileTime::DefinitionsValidator).to receive(:new).and_return(definitions_validator)
|
21
24
|
allow(StackMaster::SparkleFormation::CompileTime::ParametersValidator).to receive(:new).and_return(parameters_validator)
|
22
25
|
allow(StackMaster::SparkleFormation::CompileTime::StateBuilder).to receive(:new).and_return(state_builder)
|
26
|
+
allow(::SparkleFormation::SparkleCollection).to receive(:new).and_return(sparkle_double)
|
23
27
|
|
24
28
|
allow(sparkle_template).to receive(:parameters).and_return(compile_time_parameter_definitions)
|
29
|
+
allow(sparkle_template).to receive(:sparkle).and_return(sparkle_double)
|
30
|
+
allow(sparkle_double).to receive(:apply)
|
31
|
+
allow(sparkle_double).to receive(:set_root)
|
25
32
|
allow(definitions_validator).to receive(:validate)
|
26
33
|
allow(parameters_validator).to receive(:validate)
|
27
34
|
allow(state_builder).to receive(:build).and_return({})
|
@@ -78,4 +85,32 @@ RSpec.describe StackMaster::TemplateCompilers::SparkleFormation do
|
|
78
85
|
|
79
86
|
end
|
80
87
|
|
88
|
+
describe '.compile with sparkle packs' do
|
89
|
+
let(:compile_time_parameters) { {} }
|
90
|
+
subject(:compile) { described_class.compile(template_file_path, compile_time_parameters, compiler_options)}
|
91
|
+
|
92
|
+
context 'with a sparkle_pack loaded' do
|
93
|
+
let(:template_file_path) { File.join(File.dirname(__FILE__), "..", "..", "fixtures", "sparkle_pack_integration", "templates", "template_with_dynamic_from_pack.rb")}
|
94
|
+
let(:compiler_options) { {"sparkle_packs" => ["my_sparkle_pack"]} }
|
95
|
+
|
96
|
+
before do
|
97
|
+
lib = File.join(File.dirname(__FILE__), "..", "..", "fixtures", "sparkle_pack_integration", "my_sparkle_pack", "lib")
|
98
|
+
puts "Loading from #{lib}"
|
99
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'pulls the dynamic from the sparkle pack' do
|
103
|
+
expect(compile).to eq(%Q({\n \"Outputs\": {\n \"Foo\": {\n \"Value\": \"bar\"\n }\n }\n}))
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'without a sparkle_pack loaded' do
|
108
|
+
let(:template_file_path) { File.join(File.dirname(__FILE__), "..", "..", "fixtures", "sparkle_pack_integration", "templates", "template_with_dynamic.rb")}
|
109
|
+
let(:compiler_options) { {} }
|
110
|
+
|
111
|
+
it 'pulls the dynamic from the local path' do
|
112
|
+
expect(compile).to eq(%Q({\n \"Outputs\": {\n \"Bar\": {\n \"Value\": \"local_dynamic\"\n }\n }\n}))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
81
116
|
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: 1.
|
4
|
+
version: 1.3.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: 2018-
|
12
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -396,6 +396,11 @@ files:
|
|
396
396
|
- script/buildkite_rspec.sh
|
397
397
|
- spec/fixtures/parameters/myapp_vpc.yml
|
398
398
|
- spec/fixtures/parameters/myapp_vpc_with_secrets.yml
|
399
|
+
- spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/my_sparkle_pack.rb
|
400
|
+
- spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/sparkleformation/dynamics/my_dynamic.rb
|
401
|
+
- spec/fixtures/sparkle_pack_integration/templates/dynamics/local_dynamic.rb
|
402
|
+
- spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic.rb
|
403
|
+
- spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic_from_pack.rb
|
399
404
|
- spec/fixtures/stack_master.yml
|
400
405
|
- spec/fixtures/templates/json/valid_myapp_vpc.json
|
401
406
|
- spec/fixtures/templates/myapp_vpc.json
|
@@ -515,6 +520,11 @@ test_files:
|
|
515
520
|
- features/validate.feature
|
516
521
|
- spec/fixtures/parameters/myapp_vpc.yml
|
517
522
|
- spec/fixtures/parameters/myapp_vpc_with_secrets.yml
|
523
|
+
- spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/my_sparkle_pack.rb
|
524
|
+
- spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib/sparkleformation/dynamics/my_dynamic.rb
|
525
|
+
- spec/fixtures/sparkle_pack_integration/templates/dynamics/local_dynamic.rb
|
526
|
+
- spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic.rb
|
527
|
+
- spec/fixtures/sparkle_pack_integration/templates/template_with_dynamic_from_pack.rb
|
518
528
|
- spec/fixtures/stack_master.yml
|
519
529
|
- spec/fixtures/templates/json/valid_myapp_vpc.json
|
520
530
|
- spec/fixtures/templates/myapp_vpc.json
|