sparkle_formation 3.0.10 → 3.0.12
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/CHANGELOG.md +6 -0
- data/LICENSE +1 -1
- data/docs/sparkle-packs.md +1 -1
- data/lib/sparkle_formation/function_struct.rb +60 -6
- data/lib/sparkle_formation/provider/aws.rb +11 -6
- data/lib/sparkle_formation/provider/terraform.rb +146 -0
- data/lib/sparkle_formation/provider.rb +1 -0
- data/lib/sparkle_formation/resources/aws_resources.json +1567 -209
- data/lib/sparkle_formation/resources/azure_resources.json +4247 -1260
- data/lib/sparkle_formation/resources/heat_resources.json +1365 -704
- data/lib/sparkle_formation/resources/rackspace_resources.json +1159 -60
- data/lib/sparkle_formation/resources/terraform.rb +47 -0
- data/lib/sparkle_formation/resources/terraform_resources.json +1 -0
- data/lib/sparkle_formation/resources.rb +1 -0
- data/lib/sparkle_formation/sparkle_attribute/aws.rb +23 -0
- data/lib/sparkle_formation/sparkle_attribute/terraform.rb +151 -0
- data/lib/sparkle_formation/sparkle_attribute.rb +1 -0
- data/lib/sparkle_formation/sparkle_formation.rb +1 -1
- data/lib/sparkle_formation/version.rb +1 -1
- data/lib/sparkle_formation.rb +1 -18
- data/sparkle_formation.gemspec +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b28c5665d40741d8d5b93f3c2e3386cf5045f5
|
4
|
+
data.tar.gz: fe9953246e87f0330981402c8f24017e0ce772d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 221fa63f32b1b58ff7b06315ef97b7ca9f92f804dc1162a38ef8676a4f1baf9cc7932a2869df3d56cb59b9aed5b58e65ca674c1cad3ebef08145da421ac8d214
|
7
|
+
data.tar.gz: 86458dcb43d3e07c087d271bcdc0434ba1ae5c76604294e16569357bd59b993528ad5a6a80d9ad24ef80a497103c1877119194b68c0dfeec19cc02e9bce19bb2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v3.0.12
|
2
|
+
* Prevent parameter mappings applying to root template
|
3
|
+
* Add #import_value! helper for AWS templates (#193)
|
4
|
+
* Add #split! helper for AWS templates
|
5
|
+
* Add provider support for Terraform (#201)
|
6
|
+
|
1
7
|
# v3.0.10
|
2
8
|
* Extract pack name using previously extract path (#180)
|
3
9
|
|
data/LICENSE
CHANGED
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright 2017 Chris Roberts
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/docs/sparkle-packs.md
CHANGED
@@ -83,7 +83,8 @@ class SparkleFormation
|
|
83
83
|
if(arg.respond_to?(:_dump))
|
84
84
|
arg._dump
|
85
85
|
elsif(arg.is_a?(::Symbol))
|
86
|
-
"'
|
86
|
+
quote = __single_quote_strings ? "'" : '"'
|
87
|
+
"#{quote}#{::Bogo::Utility.camel(arg.to_s, false)}#{quote}"
|
87
88
|
elsif(arg.is_a?(::String) && __single_quote_strings)
|
88
89
|
"'#{arg}'"
|
89
90
|
else
|
@@ -99,7 +100,14 @@ class SparkleFormation
|
|
99
100
|
suffix
|
100
101
|
].compact
|
101
102
|
)
|
102
|
-
root? ?
|
103
|
+
if(root? || (!__single_anchor? && function_name))
|
104
|
+
if(!root? && __quote_nested_funcs?)
|
105
|
+
quote = __single_quote_strings ? "'" : '"'
|
106
|
+
end
|
107
|
+
"#{quote}#{__anchor_start}#{internal}#{__anchor_stop}#{quote}"
|
108
|
+
else
|
109
|
+
internal
|
110
|
+
end
|
103
111
|
else
|
104
112
|
suffix
|
105
113
|
end
|
@@ -121,6 +129,15 @@ class SparkleFormation
|
|
121
129
|
end
|
122
130
|
end
|
123
131
|
|
132
|
+
def __quote_nested_funcs?
|
133
|
+
false
|
134
|
+
end
|
135
|
+
|
136
|
+
# @return [TrueClass] wrap in single anchor
|
137
|
+
def __single_anchor?
|
138
|
+
true
|
139
|
+
end
|
140
|
+
|
124
141
|
# @return [Class]
|
125
142
|
def _klass
|
126
143
|
::SparkleFormation::FunctionStruct
|
@@ -161,8 +178,6 @@ class SparkleFormation
|
|
161
178
|
# FunctionStruct for jinja expressions
|
162
179
|
class JinjaExpressionStruct < FunctionStruct
|
163
180
|
|
164
|
-
SINGLE_QUOTE_STRINGS = false
|
165
|
-
|
166
181
|
# @return [String] start character(s) used to anchor function call
|
167
182
|
def __anchor_start
|
168
183
|
'{{ '
|
@@ -193,8 +208,6 @@ class SparkleFormation
|
|
193
208
|
# FunctionStruct for jinja statements
|
194
209
|
class JinjaStatementStruct < FunctionStruct
|
195
210
|
|
196
|
-
SINGLE_QUOTE_STRINGS = false
|
197
|
-
|
198
211
|
# @return [String] start character(s) used to anchor function call
|
199
212
|
def __anchor_start
|
200
213
|
'{% '
|
@@ -251,4 +264,45 @@ class SparkleFormation
|
|
251
264
|
end
|
252
265
|
|
253
266
|
end
|
267
|
+
|
268
|
+
# FunctionStruct for customized terraform functions
|
269
|
+
class TerraformStruct < FunctionStruct
|
270
|
+
|
271
|
+
SINGLE_ANCHOR = true
|
272
|
+
|
273
|
+
# @return [String] start character(s) used to anchor function call
|
274
|
+
def __anchor_start
|
275
|
+
'${'
|
276
|
+
end
|
277
|
+
|
278
|
+
# @return [String] stop character(s) used to anchor function call
|
279
|
+
def __anchor_stop
|
280
|
+
'}'
|
281
|
+
end
|
282
|
+
|
283
|
+
# @return [String] value to use when argument list is empty
|
284
|
+
def __empty_argument_list
|
285
|
+
''
|
286
|
+
end
|
287
|
+
|
288
|
+
# @return [FalseClass] disable single quote string generation
|
289
|
+
def __single_quote_strings
|
290
|
+
false
|
291
|
+
end
|
292
|
+
|
293
|
+
# @return [FalseClass] wrap every structure in anchors
|
294
|
+
def __single_anchor?
|
295
|
+
true
|
296
|
+
end
|
297
|
+
|
298
|
+
def __quote_nested_funcs?
|
299
|
+
false
|
300
|
+
end
|
301
|
+
|
302
|
+
# @return [Class]
|
303
|
+
def _klass
|
304
|
+
::SparkleFormation::TerraformStruct
|
305
|
+
end
|
306
|
+
|
307
|
+
end
|
254
308
|
end
|
@@ -54,11 +54,16 @@ class SparkleFormation
|
|
54
54
|
unless(stack.nested_stacks.empty?)
|
55
55
|
stack.apply_deep_nesting(*args)
|
56
56
|
end
|
57
|
-
stack.
|
58
|
-
|
59
|
-
next if
|
60
|
-
|
61
|
-
|
57
|
+
unless(stack.root?)
|
58
|
+
stack.compile.parameters.keys!.each do |parameter_name|
|
59
|
+
next if stack.compile.parameters.set!(parameter_name).stack_unique == true
|
60
|
+
if(!stack.parent.compile.parameters.set!(parameter_name).nil?)
|
61
|
+
resource.properties.parameters.set!(parameter_name, resource.ref!(parameter_name))
|
62
|
+
elsif(output_name = output_matched?(parameter_name, outputs.keys))
|
63
|
+
next if outputs[output_name] == stack
|
64
|
+
stack_output = stack.make_output_available(output_name, outputs)
|
65
|
+
resource.properties.parameters.set!(parameter_name, stack_output)
|
66
|
+
end
|
62
67
|
end
|
63
68
|
end
|
64
69
|
end
|
@@ -155,7 +160,7 @@ class SparkleFormation
|
|
155
160
|
# @param stack_resource [Hash] duplicate of stack resource contents
|
156
161
|
# @param output_map [Hash] mapping of output names to required stack output access
|
157
162
|
# @return [TrueClass]
|
158
|
-
# @note if parameter
|
163
|
+
# @note if parameter includes `StackUnique` a new parameter will
|
159
164
|
# be added to container stack and it will not use outputs
|
160
165
|
def remap_nested_parameters(template, parameters, stack_name, stack_resource, output_map)
|
161
166
|
stack_parameters = stack_resource.properties.stack.compile.parameters
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'sparkle_formation'
|
2
|
+
|
3
|
+
class SparkleFormation
|
4
|
+
module Provider
|
5
|
+
# Terraform specific implementation
|
6
|
+
module Terraform
|
7
|
+
|
8
|
+
# Customized dump to break out templates into consumable structures for
|
9
|
+
# passing to the deployment manager API
|
10
|
+
#
|
11
|
+
# @return [Hash]
|
12
|
+
def terraform_dump
|
13
|
+
result = non_terraform_dump.to_smash
|
14
|
+
Smash.new(
|
15
|
+
:parameters => :variable,
|
16
|
+
:resources => :resource,
|
17
|
+
:outputs => :output
|
18
|
+
).each do |original, updated|
|
19
|
+
if(val = result.delete(original))
|
20
|
+
result[updated] = val
|
21
|
+
end
|
22
|
+
end
|
23
|
+
if(resources = result.delete(:resource))
|
24
|
+
result[:resource] = Smash.new
|
25
|
+
resources.each do |r_name, r_info|
|
26
|
+
result.set(:resource, r_info[:type], r_name, r_info[:properties])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
# Properly remap dumping methods
|
33
|
+
def self.included(klass)
|
34
|
+
klass.class_eval do
|
35
|
+
alias_method :non_terraform_dump, :dump
|
36
|
+
alias_method :dump, :terraform_dump
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Properly remap dumping methods
|
41
|
+
def self.extended(klass)
|
42
|
+
klass.instance_eval do
|
43
|
+
alias :non_terraform_dump :dump
|
44
|
+
alias :dump :terraform_dump
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String] Type string for terraform stack resource
|
49
|
+
# @note Nested templates aren't defined as a specific type thus no "real"
|
50
|
+
# type exists. So we'll create a custom one!
|
51
|
+
def stack_resource_type
|
52
|
+
'module'
|
53
|
+
end
|
54
|
+
|
55
|
+
# Generate policy for stack
|
56
|
+
#
|
57
|
+
# @return [Hash]
|
58
|
+
def generate_policy
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
|
62
|
+
# Apply deeply nested stacks. This is the new nesting approach and
|
63
|
+
# does not bubble parameters up to the root stack. Parameters are
|
64
|
+
# isolated to the stack resource itself and output mapping is
|
65
|
+
# automatically applied.
|
66
|
+
#
|
67
|
+
# @yieldparam stack [SparkleFormation] stack instance
|
68
|
+
# @yieldparam resource [AttributeStruct] the stack resource
|
69
|
+
# @yieldparam s_name [String] stack resource name
|
70
|
+
# @yieldreturn [Hash] key/values to be merged into resource properties
|
71
|
+
# @return [SparkleFormation::SparkleStruct] compiled structure
|
72
|
+
def apply_deep_nesting(*args, &block)
|
73
|
+
outputs = collect_outputs
|
74
|
+
nested_stacks(:with_resource).each do |stack, resource|
|
75
|
+
unless(stack.nested_stacks.empty?)
|
76
|
+
stack.apply_deep_nesting(*args)
|
77
|
+
end
|
78
|
+
stack.compile.parameters.keys!.each do |parameter_name|
|
79
|
+
if(output_name = output_matched?(parameter_name, outputs.keys))
|
80
|
+
next if outputs[output_name] == stack
|
81
|
+
stack_output = stack.make_output_available(output_name, outputs, self)
|
82
|
+
# NOTE: Only set value if not already explicitly set
|
83
|
+
if(resource.properties.parameters._set(parameter_name).nil?)
|
84
|
+
resource.properties.parameters._set(parameter_name, stack_output)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
if(block_given?)
|
90
|
+
extract_templates(&block)
|
91
|
+
end
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
# Forcibly disable shallow nesting
|
96
|
+
def apply_shallow_nesting(*args, &block)
|
97
|
+
raise NotImplementedError.new 'Shallow nesting is not supported for this provider!'
|
98
|
+
end
|
99
|
+
|
100
|
+
# Extract output to make available for stack parameter usage at the
|
101
|
+
# current depth
|
102
|
+
#
|
103
|
+
# @param output_name [String] name of output
|
104
|
+
# @param outputs [Hash] listing of outputs
|
105
|
+
# @param source_stack [SparkleFormation] requesting stack
|
106
|
+
# @reutrn [Hash] reference to output value (used for setting parameter)
|
107
|
+
def make_output_available(output_name, outputs, source_stack)
|
108
|
+
bubble_path = outputs[output_name].root_path - root_path
|
109
|
+
drip_path = root_path - outputs[output_name].root_path
|
110
|
+
bubble_path.each_slice(2) do |base_sparkle, ref_sparkle|
|
111
|
+
next unless ref_sparkle
|
112
|
+
base_sparkle.compile.outputs._set(output_name)._set(
|
113
|
+
:value, base_sparkle.compile._stack_output(
|
114
|
+
ref_sparkle.name, output_name
|
115
|
+
)
|
116
|
+
)
|
117
|
+
end
|
118
|
+
if(bubble_path.empty?)
|
119
|
+
if(drip_path.size == 1)
|
120
|
+
parent = drip_path.first.parent
|
121
|
+
if(parent && !parent.compile.parameters._set(output_name).nil?)
|
122
|
+
return compile.parameter!(output_name)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
raise ArgumentError.new "Failed to detect available bubbling path for output `#{output_name}`. " <<
|
126
|
+
'This may be due to a circular dependency! ' <<
|
127
|
+
"(Output Path: #{outputs[output_name].root_path.map(&:name).join(' > ')} " <<
|
128
|
+
"Requester Path: #{root_path.map(&:name).join(' > ')})"
|
129
|
+
end
|
130
|
+
result = source_stack.compile._stack_output(bubble_path.first.name, output_name)
|
131
|
+
if(drip_path.size > 1)
|
132
|
+
parent = drip_path.first.parent
|
133
|
+
drip_path.unshift(parent) if parent
|
134
|
+
drip_path.each_slice(2) do |base_sparkle, ref_sparkle|
|
135
|
+
next unless ref_sparkle
|
136
|
+
base_sparkle.compile.resources[ref_sparkle.name].properties.parameters.value._set(output_name, result)
|
137
|
+
ref_sparkle.compile.parameters._set(output_name).type 'string' # TODO: <<<<------ type check and prop
|
138
|
+
result = compile._parameter(output_name)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
result
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|