sparkle_formation 3.0.26 → 3.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -0
- data/lib/sparkle_formation/composition.rb +17 -17
- data/lib/sparkle_formation/error.rb +2 -5
- data/lib/sparkle_formation/function_struct.rb +27 -31
- data/lib/sparkle_formation/provider/aws.rb +32 -31
- data/lib/sparkle_formation/provider/azure.rb +18 -19
- data/lib/sparkle_formation/provider/google.rb +20 -22
- data/lib/sparkle_formation/provider/heat.rb +17 -17
- data/lib/sparkle_formation/provider/terraform.rb +14 -15
- data/lib/sparkle_formation/provider.rb +0 -2
- data/lib/sparkle_formation/resources/aws.rb +129 -149
- data/lib/sparkle_formation/resources/aws_resources.json +9208 -5542
- data/lib/sparkle_formation/resources/azure.rb +2 -5
- data/lib/sparkle_formation/resources/azure_resources.json +12367 -2901
- data/lib/sparkle_formation/resources/google.rb +1 -4
- data/lib/sparkle_formation/resources/heat.rb +0 -4
- data/lib/sparkle_formation/resources/heat_resources.json +2616 -2062
- data/lib/sparkle_formation/resources/rackspace.rb +0 -4
- data/lib/sparkle_formation/resources/terraform.rb +2 -6
- data/lib/sparkle_formation/resources.rb +20 -24
- data/lib/sparkle_formation/sparkle.rb +56 -66
- data/lib/sparkle_formation/sparkle_attribute/aws.rb +61 -34
- data/lib/sparkle_formation/sparkle_attribute/azure.rb +12 -8
- data/lib/sparkle_formation/sparkle_attribute/google.rb +18 -15
- data/lib/sparkle_formation/sparkle_attribute/heat.rb +22 -7
- data/lib/sparkle_formation/sparkle_attribute/rackspace.rb +0 -2
- data/lib/sparkle_formation/sparkle_attribute/terraform.rb +11 -5
- data/lib/sparkle_formation/sparkle_attribute.rb +13 -7
- data/lib/sparkle_formation/sparkle_collection/rainbow.rb +5 -7
- data/lib/sparkle_formation/sparkle_collection.rb +13 -15
- data/lib/sparkle_formation/sparkle_formation.rb +116 -112
- data/lib/sparkle_formation/sparkle_struct.rb +30 -24
- data/lib/sparkle_formation/translation/heat.rb +57 -58
- data/lib/sparkle_formation/translation/rackspace.rb +48 -49
- data/lib/sparkle_formation/translation.rb +34 -37
- data/lib/sparkle_formation/utils.rb +6 -13
- data/lib/sparkle_formation/version.rb +1 -1
- data/sparkle_formation.gemspec +1 -1
- metadata +9 -9
@@ -16,13 +16,14 @@ class SparkleFormation
|
|
16
16
|
# @option options [String] :delimiter value used for joining items. Defaults to ''
|
17
17
|
# @return [Hash]
|
18
18
|
def _cf_join(*args)
|
19
|
-
options = args.detect{|i| i.is_a?(Hash) && i[:options]} || {:options => {}}
|
19
|
+
options = args.detect { |i| i.is_a?(Hash) && i[:options] } || {:options => {}}
|
20
20
|
args.delete(options)
|
21
|
-
unless
|
21
|
+
unless args.size == 1
|
22
22
|
args = [args]
|
23
23
|
end
|
24
24
|
{'Fn::Join' => [options[:options][:delimiter] || '', *args]}
|
25
25
|
end
|
26
|
+
|
26
27
|
alias_method :join!, :_cf_join
|
27
28
|
|
28
29
|
# Split generator
|
@@ -35,6 +36,7 @@ class SparkleFormation
|
|
35
36
|
__t_stringish(delimiter) unless delimiter.is_a?(Hash)
|
36
37
|
{'Fn::Split' => [delimiter, string]}
|
37
38
|
end
|
39
|
+
|
38
40
|
alias_method :split!, :_cf_split
|
39
41
|
|
40
42
|
# Sub generator
|
@@ -43,9 +45,14 @@ class SparkleFormation
|
|
43
45
|
# @param variables [Hash] key value mappings for substitution
|
44
46
|
# @return [Hash]
|
45
47
|
def _cf_sub(string, variables = nil)
|
46
|
-
|
47
|
-
|
48
|
+
if variables.nil?
|
49
|
+
{'Fn::Sub' => string}
|
50
|
+
else
|
51
|
+
__t_hashish(variables)
|
52
|
+
{'Fn::Sub' => [string, variables]}
|
53
|
+
end
|
48
54
|
end
|
55
|
+
|
49
56
|
alias_method :_sub, :_cf_sub
|
50
57
|
alias_method :sub!, :_cf_sub
|
51
58
|
|
@@ -58,6 +65,7 @@ class SparkleFormation
|
|
58
65
|
__t_stringish(thing)
|
59
66
|
{'Ref' => __attribute_key(thing)}
|
60
67
|
end
|
68
|
+
|
61
69
|
alias_method :_ref, :_cf_ref
|
62
70
|
alias_method :ref!, :_cf_ref
|
63
71
|
|
@@ -69,6 +77,7 @@ class SparkleFormation
|
|
69
77
|
__t_stringish(thing) unless thing.is_a?(Hash)
|
70
78
|
{'Fn::ImportValue' => __attribute_key(thing)}
|
71
79
|
end
|
80
|
+
|
72
81
|
alias_method :_import_value, :_cf_value_import
|
73
82
|
alias_method :import_value!, :_cf_value_import
|
74
83
|
|
@@ -81,18 +90,19 @@ class SparkleFormation
|
|
81
90
|
def _cf_map(thing, key, *suffix)
|
82
91
|
__t_stringish(thing)
|
83
92
|
suffix = suffix.map do |item|
|
84
|
-
if
|
93
|
+
if item.is_a?(Symbol)
|
85
94
|
_process_key(item, :force)
|
86
95
|
else
|
87
96
|
item
|
88
97
|
end
|
89
98
|
end
|
90
99
|
thing = __attribute_key(thing)
|
91
|
-
if
|
100
|
+
if key.is_a?(Symbol)
|
92
101
|
key = ref!(key)
|
93
102
|
end
|
94
103
|
{'Fn::FindInMap' => [thing, key, *suffix]}
|
95
104
|
end
|
105
|
+
|
96
106
|
alias_method :_cf_find_in_map, :_cf_map
|
97
107
|
alias_method :find_in_map!, :_cf_map
|
98
108
|
alias_method :map!, :_cf_map
|
@@ -107,7 +117,7 @@ class SparkleFormation
|
|
107
117
|
args = args.slice(1, args.size)
|
108
118
|
__t_stringish(r_name)
|
109
119
|
args = args.map do |thing|
|
110
|
-
if
|
120
|
+
if thing.is_a?(Symbol)
|
111
121
|
_process_key(thing, :force)
|
112
122
|
else
|
113
123
|
thing
|
@@ -115,6 +125,7 @@ class SparkleFormation
|
|
115
125
|
end
|
116
126
|
{'Fn::GetAtt' => [__attribute_key(r_name), *args]}
|
117
127
|
end
|
128
|
+
|
118
129
|
alias_method :_cf_get_att, :_cf_attr
|
119
130
|
alias_method :get_att!, :_cf_attr
|
120
131
|
alias_method :attr!, :_cf_attr
|
@@ -126,13 +137,14 @@ class SparkleFormation
|
|
126
137
|
def _cf_base64(arg)
|
127
138
|
{'Fn::Base64' => arg}
|
128
139
|
end
|
140
|
+
|
129
141
|
alias_method :base64!, :_cf_base64
|
130
142
|
|
131
143
|
# Fn::GetAZs generator
|
132
144
|
#
|
133
145
|
# @param region [String, Symbol] String will pass through. Symbol will be converted to ref
|
134
146
|
# @return [Hash]
|
135
|
-
def _cf_get_azs(region=nil)
|
147
|
+
def _cf_get_azs(region = nil)
|
136
148
|
region = case region
|
137
149
|
when Symbol
|
138
150
|
_cf_ref(region)
|
@@ -143,6 +155,7 @@ class SparkleFormation
|
|
143
155
|
end
|
144
156
|
{'Fn::GetAZs' => region}
|
145
157
|
end
|
158
|
+
|
146
159
|
alias_method :get_azs!, :_cf_get_azs
|
147
160
|
alias_method :azs!, :_cf_get_azs
|
148
161
|
|
@@ -156,6 +169,7 @@ class SparkleFormation
|
|
156
169
|
item = _cf_ref(item) if item.is_a?(Symbol)
|
157
170
|
{'Fn::Select' => [index, item]}
|
158
171
|
end
|
172
|
+
|
159
173
|
alias_method :select!, :_cf_select
|
160
174
|
|
161
175
|
# Condition generator
|
@@ -166,6 +180,7 @@ class SparkleFormation
|
|
166
180
|
__t_stringish(name)
|
167
181
|
{'Condition' => __attribute_key(name)}
|
168
182
|
end
|
183
|
+
|
169
184
|
alias_method :condition!, :_condition
|
170
185
|
|
171
186
|
# Condition setter
|
@@ -177,6 +192,7 @@ class SparkleFormation
|
|
177
192
|
def _on_condition(name)
|
178
193
|
_set(*_condition(name).to_a.flatten)
|
179
194
|
end
|
195
|
+
|
180
196
|
alias_method :on_condition!, :_on_condition
|
181
197
|
|
182
198
|
# Fn::If generator
|
@@ -188,6 +204,7 @@ class SparkleFormation
|
|
188
204
|
def _if(cond, true_value, false_value)
|
189
205
|
{'Fn::If' => _array(__attribute_key(cond), true_value, false_value)}
|
190
206
|
end
|
207
|
+
|
191
208
|
alias_method :if!, :_if
|
192
209
|
|
193
210
|
# Fn::And generator
|
@@ -199,16 +216,17 @@ class SparkleFormation
|
|
199
216
|
def _and(*args)
|
200
217
|
{
|
201
218
|
'Fn::And' => _array(
|
202
|
-
*args.map{|v|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
)
|
219
|
+
*args.map { |v|
|
220
|
+
if v.is_a?(Symbol) || v.is_a?(String)
|
221
|
+
_condition(v)
|
222
|
+
else
|
223
|
+
v
|
224
|
+
end
|
225
|
+
}
|
226
|
+
),
|
210
227
|
}
|
211
228
|
end
|
229
|
+
|
212
230
|
alias_method :and!, :_and
|
213
231
|
|
214
232
|
# Fn::Equals generator
|
@@ -219,6 +237,7 @@ class SparkleFormation
|
|
219
237
|
def _equals(v1, v2)
|
220
238
|
{'Fn::Equals' => _array(v1, v2)}
|
221
239
|
end
|
240
|
+
|
222
241
|
alias_method :equals!, :_equals
|
223
242
|
|
224
243
|
# Fn::Not generator
|
@@ -226,13 +245,14 @@ class SparkleFormation
|
|
226
245
|
# @param arg [Object]
|
227
246
|
# @return [Hash]
|
228
247
|
def _not(arg)
|
229
|
-
if
|
248
|
+
if arg.is_a?(String) || arg.is_a?(Symbol)
|
230
249
|
arg = _condition(arg)
|
231
250
|
else
|
232
251
|
arg = _array(arg).first
|
233
252
|
end
|
234
253
|
{'Fn::Not' => [arg]}
|
235
254
|
end
|
255
|
+
|
236
256
|
alias_method :not!, :_not
|
237
257
|
|
238
258
|
# Fn::Or generator
|
@@ -243,16 +263,17 @@ class SparkleFormation
|
|
243
263
|
def _or(*args)
|
244
264
|
{
|
245
265
|
'Fn::Or' => _array(
|
246
|
-
*args.map{|v|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
)
|
266
|
+
*args.map { |v|
|
267
|
+
if v.is_a?(Symbol) || v.is_a?(String)
|
268
|
+
_condition(v)
|
269
|
+
else
|
270
|
+
v
|
271
|
+
end
|
272
|
+
}
|
273
|
+
),
|
254
274
|
}
|
255
275
|
end
|
276
|
+
|
256
277
|
alias_method :or!, :_or
|
257
278
|
|
258
279
|
# No value generator
|
@@ -261,6 +282,7 @@ class SparkleFormation
|
|
261
282
|
def _no_value
|
262
283
|
_ref('AWS::NoValue')
|
263
284
|
end
|
285
|
+
|
264
286
|
alias_method :no_value!, :_no_value
|
265
287
|
|
266
288
|
# Region generator
|
@@ -269,6 +291,7 @@ class SparkleFormation
|
|
269
291
|
def _region
|
270
292
|
_ref('AWS::Region')
|
271
293
|
end
|
294
|
+
|
272
295
|
alias_method :region!, :_region
|
273
296
|
|
274
297
|
# Notification ARNs generator
|
@@ -277,6 +300,7 @@ class SparkleFormation
|
|
277
300
|
def _notification_arns
|
278
301
|
_ref('AWS::NotificationARNs')
|
279
302
|
end
|
303
|
+
|
280
304
|
alias_method :notification_arns!, :_notification_arns
|
281
305
|
|
282
306
|
# Account ID generator
|
@@ -285,6 +309,7 @@ class SparkleFormation
|
|
285
309
|
def _account_id
|
286
310
|
_ref('AWS::AccountId')
|
287
311
|
end
|
312
|
+
|
288
313
|
alias_method :account_id!, :_account_id
|
289
314
|
|
290
315
|
# Stack ID generator
|
@@ -293,6 +318,7 @@ class SparkleFormation
|
|
293
318
|
def _stack_id
|
294
319
|
_ref('AWS::StackId')
|
295
320
|
end
|
321
|
+
|
296
322
|
alias_method :stack_id!, :_stack_id
|
297
323
|
|
298
324
|
# Stack name generator
|
@@ -301,6 +327,7 @@ class SparkleFormation
|
|
301
327
|
def _stack_name
|
302
328
|
_ref('AWS::StackName')
|
303
329
|
end
|
330
|
+
|
304
331
|
alias_method :stack_name!, :_stack_name
|
305
332
|
|
306
333
|
# Resource dependency generator
|
@@ -313,8 +340,9 @@ class SparkleFormation
|
|
313
340
|
# @return [Array<String>]
|
314
341
|
# @note this will directly modify the struct at its current context to inject depends on structure
|
315
342
|
def _depends_on(*args)
|
316
|
-
_set('DependsOn', [args].flatten.compact.map{|s| __attribute_key(s)})
|
343
|
+
_set('DependsOn', [args].flatten.compact.map { |s| __attribute_key(s) })
|
317
344
|
end
|
345
|
+
|
318
346
|
alias_method :depends_on!, :_depends_on
|
319
347
|
|
320
348
|
# Reference output value from nested stack
|
@@ -324,15 +352,16 @@ class SparkleFormation
|
|
324
352
|
def _stack_output(stack_name, output_name)
|
325
353
|
_cf_attr(_process_key(stack_name), "Outputs.#{__attribute_key(output_name)}")
|
326
354
|
end
|
355
|
+
|
327
356
|
alias_method :stack_output!, :_stack_output
|
328
357
|
|
329
358
|
# @return [TrueClass, FalseClass] resource can be tagged
|
330
359
|
def taggable?
|
331
|
-
if
|
360
|
+
if self[:type]
|
332
361
|
resource = _self._provider._resources.lookup(self[:type].gsub('::', '_').downcase)
|
333
362
|
resource && resource[:properties].include?('Tags')
|
334
363
|
else
|
335
|
-
if
|
364
|
+
if _parent
|
336
365
|
_parent.taggable?
|
337
366
|
end
|
338
367
|
end
|
@@ -345,14 +374,12 @@ class SparkleFormation
|
|
345
374
|
def _tags(hash)
|
346
375
|
__t_hashish(hash)
|
347
376
|
_set('Tags',
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
)
|
377
|
+
hash.map { |k, v|
|
378
|
+
{'Key' => __attribute_key(k), 'Value' => v}
|
379
|
+
})
|
352
380
|
end
|
353
|
-
alias_method :tags!, :_tags
|
354
381
|
|
382
|
+
alias_method :tags!, :_tags
|
355
383
|
end
|
356
|
-
|
357
384
|
end
|
358
385
|
end
|
@@ -14,7 +14,7 @@ class SparkleFormation
|
|
14
14
|
# @param hash [Hash] template dump
|
15
15
|
# @return [Hash]
|
16
16
|
def self.resources_formatter(hash)
|
17
|
-
if
|
17
|
+
if hash.key?('resources') && !hash['resources'].is_a?(Array)
|
18
18
|
resources = hash.delete('resources')
|
19
19
|
hash['resources'] = Array.new
|
20
20
|
resources.each do |r_name, r_contents|
|
@@ -34,11 +34,12 @@ class SparkleFormation
|
|
34
34
|
klass.class_eval do
|
35
35
|
def _azure_dump
|
36
36
|
result = _attribute_struct_dump
|
37
|
-
if
|
37
|
+
if _parent.nil?
|
38
38
|
result = ::SparkleFormation::SparkleAttribute::Azure.resources_formatter(result)
|
39
39
|
end
|
40
40
|
result
|
41
41
|
end
|
42
|
+
|
42
43
|
alias_method :_attribute_struct_dump, :_dump
|
43
44
|
alias_method :_dump, :_azure_dump
|
44
45
|
alias_method :dump!, :_azure_dump
|
@@ -73,7 +74,7 @@ class SparkleFormation
|
|
73
74
|
'providers',
|
74
75
|
'reference',
|
75
76
|
'resourceGroup',
|
76
|
-
'subscription'
|
77
|
+
'subscription',
|
77
78
|
]
|
78
79
|
|
79
80
|
# NOTE: Alias implementation disabled due to Ruby 2.3 __callee__ bug
|
@@ -110,6 +111,7 @@ class SparkleFormation
|
|
110
111
|
x._fn_context = self
|
111
112
|
x
|
112
113
|
end
|
114
|
+
|
113
115
|
alias_method :variables!, :_variables
|
114
116
|
|
115
117
|
# @overload _resource_id(resource_name)
|
@@ -119,14 +121,14 @@ class SparkleFormation
|
|
119
121
|
# @param [String, Symbol] name of resource
|
120
122
|
# @return [FunctionStruct]
|
121
123
|
def _resource_id(*args)
|
122
|
-
if
|
124
|
+
if args.size > 1
|
123
125
|
::SparkleFormation::FunctionStruct.new('resourceId', *args)
|
124
126
|
else
|
125
127
|
r_name = args.first
|
126
128
|
resource = _root.resources.set!(r_name)
|
127
|
-
if
|
129
|
+
if resource.nil?
|
128
130
|
::Kernel.raise ::SparkleFormation::Error::NotFound::Resource.new(:name => r_name)
|
129
|
-
elsif
|
131
|
+
elsif resource.type.nil?
|
130
132
|
::Kernel.raise ::SparkleFormation::Error::InvalidResource.new(
|
131
133
|
"Resource `#{r_name}` provides no type information."
|
132
134
|
)
|
@@ -139,6 +141,7 @@ class SparkleFormation
|
|
139
141
|
end
|
140
142
|
end
|
141
143
|
end
|
144
|
+
|
142
145
|
alias_method :resource_id!, :_resource_id
|
143
146
|
|
144
147
|
# Resource dependency generator
|
@@ -155,7 +158,7 @@ class SparkleFormation
|
|
155
158
|
case item
|
156
159
|
when ::Symbol
|
157
160
|
resource = _root.resources.set!(item)
|
158
|
-
if
|
161
|
+
if resource.nil?
|
159
162
|
::Kernel.raise ::SparkleFormation::Error::NotFound::Resource.new(:name => item)
|
160
163
|
else
|
161
164
|
[resource.type, resource.resource_name!].join('/')
|
@@ -166,6 +169,7 @@ class SparkleFormation
|
|
166
169
|
end
|
167
170
|
set!(:depends_on, args)
|
168
171
|
end
|
172
|
+
|
169
173
|
alias_method :depends_on!, :_depends_on
|
170
174
|
|
171
175
|
# Reference output value from nested stack
|
@@ -180,8 +184,8 @@ class SparkleFormation
|
|
180
184
|
o_root.outputs.set!(output_name).value
|
181
185
|
o_root
|
182
186
|
end
|
183
|
-
alias_method :stack_output!, :_stack_output
|
184
187
|
|
188
|
+
alias_method :stack_output!, :_stack_output
|
185
189
|
end
|
186
190
|
end
|
187
191
|
end
|
@@ -6,7 +6,6 @@ class SparkleFormation
|
|
6
6
|
|
7
7
|
# Google specific helper implementations
|
8
8
|
module Google
|
9
|
-
|
10
9
|
CHARACTER_COLLECTION = ('a'..'z').to_a
|
11
10
|
|
12
11
|
def self.included(klass)
|
@@ -15,9 +14,9 @@ class SparkleFormation
|
|
15
14
|
klass.class_eval do
|
16
15
|
def _google_dump
|
17
16
|
result = _non_google_attribute_struct_dump
|
18
|
-
if
|
17
|
+
if _parent.nil?
|
19
18
|
sparkle_root = {}
|
20
|
-
if
|
19
|
+
if result.key?('resources') && result['resources'].is_a?(Hash)
|
21
20
|
resources = result.delete('resources') || {}
|
22
21
|
sparkle_root = (resources.delete(_self.name) || {}).fetch('properties', {})
|
23
22
|
result['resources'] = resources.map do |r_name, r_content|
|
@@ -27,21 +26,22 @@ class SparkleFormation
|
|
27
26
|
result['outputs'] = outputs.map do |o_name, o_content|
|
28
27
|
o_content.merge('name' => o_name)
|
29
28
|
end
|
30
|
-
if
|
29
|
+
if _self.parent.nil?
|
31
30
|
result = {
|
32
31
|
'resources' => [{
|
33
32
|
'name' => _self.name,
|
34
33
|
'type' => _self.stack_resource_type,
|
35
34
|
'properties' => {
|
36
|
-
'stack' => result
|
37
|
-
}.merge(sparkle_root)
|
38
|
-
}]
|
35
|
+
'stack' => result,
|
36
|
+
}.merge(sparkle_root),
|
37
|
+
}],
|
39
38
|
}
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
43
42
|
result
|
44
43
|
end
|
44
|
+
|
45
45
|
alias_method :_non_google_attribute_struct_dump, :_dump
|
46
46
|
alias_method :_dump, :_google_dump
|
47
47
|
alias_method :dump!, :_google_dump
|
@@ -56,17 +56,16 @@ class SparkleFormation
|
|
56
56
|
# @see SparkleFormation::SparkleAttribute#dynamic!
|
57
57
|
# @note generate unique names using the `:sparkle_unique` argument
|
58
58
|
def _google_dynamic!(name, *args, &block)
|
59
|
-
if
|
59
|
+
if args.delete(:sparkle_unique)
|
60
60
|
seed = Zlib.crc32(_self.root_path.map(&:name).join('-'))
|
61
61
|
gen = Random.new(seed)
|
62
62
|
suffix = Array.new(10) do
|
63
63
|
CHARACTER_COLLECTION.at(
|
64
|
-
gen.rand(CHARACTER_COLLECTION.size
|
65
|
-
)
|
64
|
+
gen.rand(CHARACTER_COLLECTION.size)
|
66
65
|
)
|
67
66
|
end.join
|
68
|
-
config_hash = args.detect{|a| a.is_a?(Hash)}
|
69
|
-
unless
|
67
|
+
config_hash = args.detect { |a| a.is_a?(Hash) }
|
68
|
+
unless config_hash
|
70
69
|
config_hash = {}
|
71
70
|
args.push(config_hash)
|
72
71
|
end
|
@@ -83,12 +82,13 @@ class SparkleFormation
|
|
83
82
|
# @return [SparkleFormation::GoogleStruct]
|
84
83
|
def _ref(r_name)
|
85
84
|
__t_stringish(r_name)
|
86
|
-
if
|
85
|
+
if _root.resources.set!(r_name).nil?
|
87
86
|
::Kernel.raise ::SparkleFormation::Error::NotFound::Resource.new(:name => r_name)
|
88
87
|
else
|
89
88
|
::SparkleFormation::GoogleStruct.new('ref').set!(__attribute_key(r_name))
|
90
89
|
end
|
91
90
|
end
|
91
|
+
|
92
92
|
alias_method :ref!, :_ref
|
93
93
|
|
94
94
|
# Jinja function string wrapper
|
@@ -97,6 +97,7 @@ class SparkleFormation
|
|
97
97
|
def _jinja
|
98
98
|
::SparkleFormation::JinjaExpressionStruct.new
|
99
99
|
end
|
100
|
+
|
100
101
|
alias_method :jinja!, :_jinja
|
101
102
|
alias_method :fn!, :_jinja
|
102
103
|
|
@@ -108,6 +109,7 @@ class SparkleFormation
|
|
108
109
|
__t_stringish(e_name)
|
109
110
|
_jinja.env[__attribute_key(e_name)]
|
110
111
|
end
|
112
|
+
|
111
113
|
alias_method :env!, :_env
|
112
114
|
|
113
115
|
# Access a property value supplied to template
|
@@ -119,6 +121,7 @@ class SparkleFormation
|
|
119
121
|
__t_stringish(p_name)
|
120
122
|
_jinja.properties[__attribute_key(p_name)]
|
121
123
|
end
|
124
|
+
|
122
125
|
alias_method :property!, :_property
|
123
126
|
alias_method :properties!, :_property
|
124
127
|
|
@@ -129,6 +132,7 @@ class SparkleFormation
|
|
129
132
|
def _statement(line)
|
130
133
|
::SparkleFormation::JinjaStatementStruct.new(line)
|
131
134
|
end
|
135
|
+
|
132
136
|
alias_method :statement!, :_statement
|
133
137
|
|
134
138
|
# Reference output value from nested stack
|
@@ -141,9 +145,8 @@ class SparkleFormation
|
|
141
145
|
__t_stringish(output_name)
|
142
146
|
_ref(stack_name)._set(output_name)
|
143
147
|
end
|
144
|
-
alias_method :stack_output!, :_stack_output
|
145
148
|
|
149
|
+
alias_method :stack_output!, :_stack_output
|
146
150
|
end
|
147
|
-
|
148
151
|
end
|
149
152
|
end
|
@@ -10,7 +10,7 @@ class SparkleFormation
|
|
10
10
|
|
11
11
|
# Set customized struct behavior
|
12
12
|
def self.included(klass)
|
13
|
-
if
|
13
|
+
if klass.const_defined?(:CAMEL_KEYS)
|
14
14
|
klass.send(:remove_const, :CAMEL_KEYS)
|
15
15
|
end
|
16
16
|
klass.const_set(:CAMEL_KEYS, false)
|
@@ -28,6 +28,7 @@ class SparkleFormation
|
|
28
28
|
end
|
29
29
|
{'get_attr' => args}
|
30
30
|
end
|
31
|
+
|
31
32
|
alias_method :_attr, :_get_attr
|
32
33
|
alias_method :attr!, :_get_attr
|
33
34
|
|
@@ -39,13 +40,14 @@ class SparkleFormation
|
|
39
40
|
# @option options [String] :delimiter value used for joining items. Defaults to ''
|
40
41
|
# @return [Hash]
|
41
42
|
def _list_join(*args)
|
42
|
-
options = args.detect{|i| i.is_a?(::Hash) && i[:options]} || {:options => {}}
|
43
|
+
options = args.detect { |i| i.is_a?(::Hash) && i[:options] } || {:options => {}}
|
43
44
|
args.delete(options)
|
44
|
-
unless
|
45
|
+
unless args.size == 1
|
45
46
|
args = [args]
|
46
47
|
end
|
47
48
|
{'list_join' => [options[:options][:delimiter] || '', *args]}
|
48
49
|
end
|
50
|
+
|
49
51
|
alias_method :_join, :_list_join
|
50
52
|
alias_method :join!, :_list_join
|
51
53
|
|
@@ -57,6 +59,7 @@ class SparkleFormation
|
|
57
59
|
__t_stringish(loc)
|
58
60
|
{'get_file' => loc}
|
59
61
|
end
|
62
|
+
|
60
63
|
alias_method :_file, :_get_file
|
61
64
|
alias_method :file!, :_get_file
|
62
65
|
|
@@ -76,6 +79,7 @@ class SparkleFormation
|
|
76
79
|
end
|
77
80
|
{'get_param' => args.size == 1 ? args.first : args}
|
78
81
|
end
|
82
|
+
|
79
83
|
alias_method :_param, :_get_param
|
80
84
|
alias_method :param!, :_get_param
|
81
85
|
|
@@ -87,6 +91,7 @@ class SparkleFormation
|
|
87
91
|
__t_stringish(r_name)
|
88
92
|
{'get_resource' => __attribute_key(r_name)}
|
89
93
|
end
|
94
|
+
|
90
95
|
alias_method :_resource, :_get_resource
|
91
96
|
alias_method :resource!, :_get_resource
|
92
97
|
|
@@ -94,10 +99,11 @@ class SparkleFormation
|
|
94
99
|
#
|
95
100
|
# @param value [String, Hash] thing to be hashed
|
96
101
|
# @param algorithm [String] algorithm to use (defaults to 'sha512')
|
97
|
-
def _digest(value, algorithm='sha512')
|
102
|
+
def _digest(value, algorithm = 'sha512')
|
98
103
|
__t_stringish(algorithm)
|
99
104
|
{'digest' => [algorithm, value]}
|
100
105
|
end
|
106
|
+
|
101
107
|
alias_method :digest!, :_digest
|
102
108
|
|
103
109
|
# resource_facade generator
|
@@ -108,6 +114,7 @@ class SparkleFormation
|
|
108
114
|
__t_stringish(type)
|
109
115
|
{'resource_facade' => type}
|
110
116
|
end
|
117
|
+
|
111
118
|
alias_method :_facade, :_resource_facade
|
112
119
|
alias_method :facade!, :_resource_facade
|
113
120
|
alias_method :resource_facade!, :_resource_facade
|
@@ -122,6 +129,7 @@ class SparkleFormation
|
|
122
129
|
__t_hashish(params)
|
123
130
|
{'str_replace' => {'template' => template, 'params' => params}}
|
124
131
|
end
|
132
|
+
|
125
133
|
alias_method :_replace, :_str_replace
|
126
134
|
alias_method :replace!, :_str_replace
|
127
135
|
|
@@ -131,10 +139,11 @@ class SparkleFormation
|
|
131
139
|
# @param string [Object]
|
132
140
|
# @param idx [Numeric]
|
133
141
|
# @return [Hash]
|
134
|
-
def _str_split(splitter, string, idx=nil)
|
142
|
+
def _str_split(splitter, string, idx = nil)
|
135
143
|
__t_stringish(splitter) unless splitter.is_a?(Hash)
|
136
144
|
{'str_split' => [splitter, string, idx].compact}
|
137
145
|
end
|
146
|
+
|
138
147
|
alias_method :_split, :_str_split
|
139
148
|
alias_method :split!, :_str_split
|
140
149
|
|
@@ -146,24 +155,28 @@ class SparkleFormation
|
|
146
155
|
def _map_merge(*args)
|
147
156
|
{'map_merge' => args}
|
148
157
|
end
|
158
|
+
|
149
159
|
alias_method :map_merge!, :_map_merge
|
150
160
|
|
151
161
|
# @return [Hash]
|
152
162
|
def _stack_id
|
153
163
|
_get_param('OS::stack_id')
|
154
164
|
end
|
165
|
+
|
155
166
|
alias_method :stack_id!, :_stack_id
|
156
167
|
|
157
168
|
# @return [Hash]
|
158
169
|
def _stack_name
|
159
170
|
_get_param('OS::stack_name')
|
160
171
|
end
|
172
|
+
|
161
173
|
alias_method :stack_name!, :_stack_name
|
162
174
|
|
163
175
|
# @return [Hash]
|
164
176
|
def _project_id
|
165
177
|
_get_param('OS::project_id')
|
166
178
|
end
|
179
|
+
|
167
180
|
alias_method :project_id!, :_project_id
|
168
181
|
|
169
182
|
# Resource dependency generator
|
@@ -176,8 +189,9 @@ class SparkleFormation
|
|
176
189
|
# @return [Array<String>]
|
177
190
|
# @note this will directly modify the struct at its current context to inject depends on structure
|
178
191
|
def _depends_on(*args)
|
179
|
-
_set('depends_on', [args].flatten.compact.map{|s| __attribute_key(s) })
|
192
|
+
_set('depends_on', [args].flatten.compact.map { |s| __attribute_key(s) })
|
180
193
|
end
|
194
|
+
|
181
195
|
alias_method :depends_on!, :_depends_on
|
182
196
|
|
183
197
|
# Reference output value from nested stack
|
@@ -191,9 +205,10 @@ class SparkleFormation
|
|
191
205
|
__attribute_key(output_name)
|
192
206
|
)
|
193
207
|
end
|
194
|
-
alias_method :stack_output!, :_stack_output
|
195
208
|
|
209
|
+
alias_method :stack_output!, :_stack_output
|
196
210
|
end
|
211
|
+
|
197
212
|
OpenStack = Heat
|
198
213
|
end
|
199
214
|
end
|