stack_master 1.16.0 → 1.17.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/README.md +3 -1
- data/lib/stack_master/stack.rb +1 -1
- data/lib/stack_master/stack_definition.rb +8 -2
- data/lib/stack_master/template_compiler.rb +19 -13
- data/lib/stack_master/template_compilers/cfndsl.rb +2 -1
- data/lib/stack_master/template_compilers/json.rb +2 -1
- data/lib/stack_master/template_compilers/sparkle_formation.rb +8 -6
- data/lib/stack_master/template_compilers/yaml.rb +2 -1
- data/lib/stack_master/validator.rb +1 -2
- data/lib/stack_master/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae4eccac3702f32e8c22434fb946e19d3d29a76789a68e66a18c292924c3138
|
4
|
+
data.tar.gz: 13f4ae0b29aaa518a584d277e9329c16860725bc0b119be5e124d6a7c47ddefe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a069c5c2df3f5cece5a647dc9239926440c97aea6e2f28999bd0f725e0fca3da3144d26b21cd3dd62ac52f0208606be9423f642b85981f6de9f212f5dfc297
|
7
|
+
data.tar.gz: bfb4d57cad111a3a8f4519c19ac2aa6f3ece8e3d2fd4125f97cb2fc28fe2897b016d2da89f8aa92949c9b690c2ebb6cd060035664da673da8064a69781617059
|
data/README.md
CHANGED
@@ -602,10 +602,12 @@ we can use stack defined as follows:
|
|
602
602
|
stacks:
|
603
603
|
us-east-1:
|
604
604
|
my-stack:
|
605
|
-
|
605
|
+
template: template_name
|
606
|
+
compiler: sparkle_formation
|
606
607
|
compiler_options:
|
607
608
|
sparkle_packs:
|
608
609
|
- some-sparkle-pack
|
610
|
+
sparkle_pack_template: true
|
609
611
|
```
|
610
612
|
|
611
613
|
## Allowed accounts
|
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.
|
68
|
+
template_body = TemplateCompiler.compile(config, stack_definition.compiler, stack_definition.template_dir, stack_definition.template, 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)
|
@@ -3,7 +3,6 @@ module StackMaster
|
|
3
3
|
attr_accessor :region,
|
4
4
|
:stack_name,
|
5
5
|
:template,
|
6
|
-
:sparkle_pack_template,
|
7
6
|
:tags,
|
8
7
|
:role_arn,
|
9
8
|
:allowed_accounts,
|
@@ -20,6 +19,8 @@ module StackMaster
|
|
20
19
|
:files,
|
21
20
|
:compiler_options
|
22
21
|
|
22
|
+
attr_reader :compiler
|
23
|
+
|
23
24
|
include Utils::Initializable
|
24
25
|
|
25
26
|
def initialize(attributes = {})
|
@@ -30,6 +31,7 @@ module StackMaster
|
|
30
31
|
@files = []
|
31
32
|
@allowed_accounts = nil
|
32
33
|
@ejson_file_kms = true
|
34
|
+
@compiler = nil
|
33
35
|
super
|
34
36
|
@template_dir ||= File.join(@base_dir, 'templates')
|
35
37
|
@allowed_accounts = Array(@allowed_accounts)
|
@@ -40,7 +42,6 @@ module StackMaster
|
|
40
42
|
@region == other.region &&
|
41
43
|
@stack_name == other.stack_name &&
|
42
44
|
@template == other.template &&
|
43
|
-
@sparkle_pack_template == other.sparkle_pack_template &&
|
44
45
|
@tags == other.tags &&
|
45
46
|
@role_arn == other.role_arn &&
|
46
47
|
@allowed_accounts == other.allowed_accounts &&
|
@@ -53,9 +54,14 @@ module StackMaster
|
|
53
54
|
@stack_policy_file == other.stack_policy_file &&
|
54
55
|
@additional_parameter_lookup_dirs == other.additional_parameter_lookup_dirs &&
|
55
56
|
@s3 == other.s3 &&
|
57
|
+
@compiler == other.compiler &&
|
56
58
|
@compiler_options == other.compiler_options
|
57
59
|
end
|
58
60
|
|
61
|
+
def compiler=(compiler)
|
62
|
+
@compiler = compiler.&to_sym
|
63
|
+
end
|
64
|
+
|
59
65
|
def template_file_path
|
60
66
|
return unless template
|
61
67
|
File.expand_path(File.join(template_dir, template))
|
@@ -2,12 +2,16 @@ module StackMaster
|
|
2
2
|
class TemplateCompiler
|
3
3
|
TemplateCompilationFailed = Class.new(RuntimeError)
|
4
4
|
|
5
|
-
def self.compile(config,
|
6
|
-
compiler =
|
5
|
+
def self.compile(config, template_compiler, template_dir, template, compile_time_parameters, compiler_options = {})
|
6
|
+
compiler = if template_compiler
|
7
|
+
find_compiler(template_compiler)
|
8
|
+
else
|
9
|
+
template_compiler_for_stack(template, config)
|
10
|
+
end
|
7
11
|
compiler.require_dependencies
|
8
|
-
compiler.compile(template_dir,
|
12
|
+
compiler.compile(template_dir, template, compile_time_parameters, compiler_options)
|
9
13
|
rescue StandardError => e
|
10
|
-
raise TemplateCompilationFailed.new("Failed to compile #{
|
14
|
+
raise TemplateCompilationFailed.new("Failed to compile #{template} with error #{e}.\n#{e.backtrace}")
|
11
15
|
end
|
12
16
|
|
13
17
|
def self.register(name, klass)
|
@@ -16,20 +20,22 @@ module StackMaster
|
|
16
20
|
end
|
17
21
|
|
18
22
|
# private
|
19
|
-
def self.template_compiler_for_stack(
|
20
|
-
ext =
|
21
|
-
:rb
|
22
|
-
else
|
23
|
-
file_ext(template_file_path)
|
24
|
-
end
|
23
|
+
def self.template_compiler_for_stack(template, config)
|
24
|
+
ext = file_ext(template)
|
25
25
|
compiler_name = config.template_compilers.fetch(ext)
|
26
|
-
|
26
|
+
find_compiler(compiler_name)
|
27
27
|
end
|
28
28
|
private_class_method :template_compiler_for_stack
|
29
29
|
|
30
|
-
def self.file_ext(
|
31
|
-
File.extname(
|
30
|
+
def self.file_ext(template)
|
31
|
+
File.extname(template).gsub('.', '').to_sym
|
32
32
|
end
|
33
33
|
private_class_method :file_ext
|
34
|
+
|
35
|
+
def self.find_compiler(name)
|
36
|
+
@compilers.fetch(name.to_sym) do
|
37
|
+
raise "Unknown compiler #{name.inspect}"
|
38
|
+
end
|
39
|
+
end
|
34
40
|
end
|
35
41
|
end
|
@@ -4,10 +4,11 @@ module StackMaster::TemplateCompilers
|
|
4
4
|
require 'cfndsl'
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.compile(
|
7
|
+
def self.compile(template_dir, template, compile_time_parameters, _compiler_options = {})
|
8
8
|
CfnDsl.disable_binding
|
9
9
|
CfnDsl::ExternalParameters.defaults.clear # Ensure there's no leakage across invocations
|
10
10
|
CfnDsl::ExternalParameters.defaults(compile_time_parameters.symbolize_keys)
|
11
|
+
template_file_path = File.join(template_dir, template)
|
11
12
|
::CfnDsl.eval_file_with_extras(template_file_path).to_json
|
12
13
|
end
|
13
14
|
|
@@ -7,7 +7,8 @@ module StackMaster::TemplateCompilers
|
|
7
7
|
require 'json'
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.compile(
|
10
|
+
def self.compile(template_dir, template, _compile_time_parameters, _compiler_options = {})
|
11
|
+
template_file_path = File.join(template_dir, template)
|
11
12
|
template_body = File.read(template_file_path)
|
12
13
|
if template_body.size > MAX_TEMPLATE_SIZE
|
13
14
|
# Parse the json and rewrite compressed
|
@@ -12,8 +12,8 @@ module StackMaster::TemplateCompilers
|
|
12
12
|
require 'stack_master/sparkle_formation/template_file'
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.compile(template_dir,
|
16
|
-
sparkle_template = compile_sparkle_template(template_dir,
|
15
|
+
def self.compile(template_dir, template, compile_time_parameters, compiler_options = {})
|
16
|
+
sparkle_template = compile_sparkle_template(template_dir, template, compiler_options)
|
17
17
|
definitions = sparkle_template.parameters
|
18
18
|
validate_definitions(definitions)
|
19
19
|
validate_parameters(definitions, compile_time_parameters)
|
@@ -27,7 +27,7 @@ module StackMaster::TemplateCompilers
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def self.compile_sparkle_template(template_dir,
|
30
|
+
def self.compile_sparkle_template(template_dir, template, compiler_options)
|
31
31
|
sparkle_path = if compiler_options['sparkle_path']
|
32
32
|
File.expand_path(compiler_options['sparkle_path'])
|
33
33
|
else
|
@@ -47,9 +47,11 @@ module StackMaster::TemplateCompilers
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
if sparkle_pack_template
|
51
|
-
raise ArgumentError.new("Template #{
|
52
|
-
template_file_path = collection.templates['aws'][
|
50
|
+
if compiler_options['sparkle_pack_template']
|
51
|
+
raise ArgumentError.new("Template #{template.inspect} not found in any sparkle pack") unless collection.templates['aws'].include? template
|
52
|
+
template_file_path = collection.templates['aws'][template].top['path']
|
53
|
+
else
|
54
|
+
template_file_path = File.join(template_dir, template)
|
53
55
|
end
|
54
56
|
|
55
57
|
sparkle_template = compile_template_with_sparkle_path(template_file_path, sparkle_path)
|
@@ -5,7 +5,8 @@ module StackMaster::TemplateCompilers
|
|
5
5
|
require 'json'
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.compile(
|
8
|
+
def self.compile(template_dir, template, _compile_time_parameters, _compiler_options = {})
|
9
|
+
template_file_path = File.join(template_dir, template)
|
9
10
|
File.read(template_file_path)
|
10
11
|
end
|
11
12
|
|
@@ -14,7 +14,7 @@ module StackMaster
|
|
14
14
|
compile_time_parameters = ParameterResolver.resolve(@config, @stack_definition, parameter_hash[:compile_time_parameters])
|
15
15
|
|
16
16
|
StackMaster.stdout.print "#{@stack_definition.stack_name}: "
|
17
|
-
template_body = TemplateCompiler.compile(@config, @stack_definition.
|
17
|
+
template_body = TemplateCompiler.compile(@config, @stack_definition.compiler, @stack_definition.template_dir, @stack_definition.template, compile_time_parameters, @stack_definition.compiler_options)
|
18
18
|
cf.validate_template(template_body: TemplateUtils.maybe_compressed_template_body(template_body))
|
19
19
|
StackMaster.stdout.puts "valid"
|
20
20
|
true
|
@@ -28,6 +28,5 @@ module StackMaster
|
|
28
28
|
def cf
|
29
29
|
@cf ||= StackMaster.cloud_formation_driver
|
30
30
|
end
|
31
|
-
|
32
31
|
end
|
33
32
|
end
|
data/lib/stack_master/version.rb
CHANGED
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.17.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: 2019-08-
|
12
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -529,8 +529,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
529
529
|
- !ruby/object:Gem::Version
|
530
530
|
version: '0'
|
531
531
|
requirements: []
|
532
|
-
|
533
|
-
rubygems_version: 2.7.6.2
|
532
|
+
rubygems_version: 3.0.3
|
534
533
|
signing_key:
|
535
534
|
specification_version: 4
|
536
535
|
summary: StackMaster is a sure-footed way of creating, updating and keeping track
|