sparkle_formation 3.0.16 → 3.0.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ff339020395b4fde4837cc5e7deb4001b53ffae
4
- data.tar.gz: 0dede473ebcec2f710162af551f0a88da821b8cf
3
+ metadata.gz: 14385f4b5ede6c882f0f996a4f19c58c551d6b26
4
+ data.tar.gz: e4a313a0d73d91d7fa512d2e67dfc70f8e281e3e
5
5
  SHA512:
6
- metadata.gz: a7dae3cb305e19d69618541583e6eba0bd472a69db5d0d4d0335cf8469378ac456df131d6c5be9b2b68f2ed01b2394c8aae2c4d8b9021f38cc2e323bb349463a
7
- data.tar.gz: f6d7bea2bea0e9ae058e3d5a1769fbe286767f90627484d801111823df9d4ac2ad3b2d99d9298799e79d92693bb52ebf3280eb1dfb4c05601259071724da02f4
6
+ metadata.gz: b5ec3a38b93458caf38e9119cdcfc07c97726955ea68630af1504afd33f3a61af4e4f01a7a44623da62e448dbc0f9d5c81f40f223161d0059e7b69f1dddb0489
7
+ data.tar.gz: 5158012d4f61b3f2a1f1afcc555fd6a5004ae534b9d8a6a10b3583c82dae0ce48e4694408752d24487ff3412de2c839d7efb45997d8f4d4d237c1b904dd941a5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v3.0.18
2
+ * Fix deeply nested parameter pushing (#209)
3
+ * Remap known nested variable functions in Azure templates (#210)
4
+
1
5
  # v3.0.16
2
6
  * Allow data structure arguments in AWS helpers
3
7
  * Add AWS sub intrinsic function helper
@@ -5,6 +5,7 @@ require 'attribute_struct'
5
5
  # Unicorns and rainbows
6
6
  class SparkleFormation
7
7
  autoload :Aws, 'sparkle_formation/aws'
8
+ autoload :AzureVariableStruct, 'sparkle_formation/function_struct'
8
9
  autoload :Composition, 'sparkle_formation/composition'
9
10
  autoload :Error, 'sparkle_formation/error'
10
11
  autoload :FunctionStruct, 'sparkle_formation/function_struct'
@@ -175,6 +175,44 @@ class SparkleFormation
175
175
 
176
176
  end
177
177
 
178
+ # Function struct specialized for Azure variables to check nested
179
+ # variable function value and properly match defined case
180
+ class AzureVariableStruct < FunctionStruct
181
+ # [SparkleStruct] context of function usage
182
+ attr_reader :_fn_context
183
+
184
+ # Set current function context
185
+ #
186
+ # @param ctx [SparkleStruct] current context
187
+ # @return [SparkleStruct]
188
+ def _fn_context=(ctx)
189
+ @_fn_context = ctx
190
+ end
191
+
192
+ # Wrapper to check for nested function call and properly case
193
+ # the function if found.
194
+ def _dump
195
+ # Remap nested function keys if possible
196
+ if(_fn_context && _fn_context.root!.data![_fn_name] && _fn_context.root!.data![_fn_name].data![_fn_args.first])
197
+ __valid_keys = _fn_context.root!.data![_fn_name].data![_fn_args.first].keys!
198
+ __current_key = @table.keys.first
199
+ __match_key = __current_key.to_s.downcase.gsub('_', '')
200
+ __key_remap = __valid_keys.detect do |__nested_key|
201
+ __nested_key.to_s.downcase.gsub('_', '') == __match_key
202
+ end
203
+ if(__key_remap)
204
+ @table[__key_remap] = @table.delete(@table.keys.first)
205
+ end
206
+ end
207
+ super
208
+ end
209
+
210
+ # @return [Class]
211
+ def _klass
212
+ ::SparkleFormation::AzureVariableStruct
213
+ end
214
+ end
215
+
178
216
  # FunctionStruct for jinja expressions
179
217
  class JinjaExpressionStruct < FunctionStruct
180
218
 
@@ -57,7 +57,7 @@ class SparkleFormation
57
57
  unless(stack.root?)
58
58
  stack.compile.parameters.keys!.each do |parameter_name|
59
59
  next if stack.compile.parameters.set!(parameter_name).stack_unique == true
60
- if(!stack.parent.compile.parameters.set!(parameter_name).nil?)
60
+ if(!stack.parent.compile.parameters.data![parameter_name].nil?)
61
61
  resource.properties.parameters.set!(parameter_name, resource.ref!(parameter_name))
62
62
  elsif(output_name = output_matched?(parameter_name, outputs.keys))
63
63
  next if outputs[output_name] == stack
@@ -33,11 +33,16 @@ class SparkleFormation
33
33
  unless(stack.nested_stacks.empty?)
34
34
  stack.apply_deep_nesting(*args)
35
35
  end
36
- stack.compile.parameters.keys!.each do |parameter_name|
37
- if(output_name = output_matched?(parameter_name, outputs.keys))
38
- next if outputs[output_name] == stack
39
- stack_output = stack.make_output_available(output_name, outputs)
40
- resource.properties.parameters._set(parameter_name).value stack_output
36
+ unless(stack.root?)
37
+ stack.compile.parameters.keys!.each do |parameter_name|
38
+ next if stack.compile.parameters.set!(parameter_name).stack_unique == true
39
+ if(!stack.parent.compile.parameters.data![parameter_name].nil?)
40
+ resource.properties.parameters.set!(parameter_name, resource.ref!(parameter_name))
41
+ elsif(output_name = output_matched?(parameter_name, outputs.keys))
42
+ next if outputs[output_name] == stack
43
+ stack_output = stack.make_output_available(output_name, outputs)
44
+ resource.properties.parameters.set!(parameter_name, stack_output)
45
+ end
41
46
  end
42
47
  end
43
48
  end
@@ -69,7 +69,6 @@ class SparkleFormation
69
69
  'uri',
70
70
  'deployment',
71
71
  'parameters',
72
- 'variables',
73
72
  'listKeys',
74
73
  'providers',
75
74
  'reference',
@@ -103,6 +102,16 @@ class SparkleFormation
103
102
  alias_method "#{f_name}!".to_sym, "_#{f_name}".to_sym
104
103
  end
105
104
 
105
+ # Variables generator
106
+ #
107
+ # @return [SparkleFormation::AzureVariableStruct]
108
+ def _variables(*args)
109
+ x = ::SparkleFormation::AzureVariableStruct.new('variables', *args)
110
+ x._fn_context = self
111
+ x
112
+ end
113
+ alias_method :variables!, :_variables
114
+
106
115
  # @overload _resource_id(resource_name)
107
116
  # Customized resourceId generator that will perform automatic
108
117
  # lookup on defined resources for building the function if Symbol
@@ -755,14 +755,16 @@ class SparkleFormation
755
755
  if(compile[:resources])
756
756
  compile.resources.keys!.map do |key|
757
757
  if(stack_resource_type?(compile.resources[key].type))
758
- result = [compile.resources[key].properties.stack]
759
- if(args.include?(:with_resource))
760
- result.push(compile[:resources][key])
761
- end
762
- if(args.include?(:with_name))
763
- result.push(key)
758
+ if(compile.resources[key].properties.stack.is_a?(::SparkleFormation))
759
+ result = [compile.resources[key].properties.stack]
760
+ if(args.include?(:with_resource))
761
+ result.push(compile[:resources][key])
762
+ end
763
+ if(args.include?(:with_name))
764
+ result.push(key)
765
+ end
766
+ result.size == 1 ? result.first : result
764
767
  end
765
- result.size == 1 ? result.first : result
766
768
  end
767
769
  end.compact
768
770
  else
@@ -1,5 +1,5 @@
1
1
  # Unicorns and rainbows
2
2
  class SparkleFormation
3
3
  # Current library version
4
- VERSION = Gem::Version.new('3.0.16')
4
+ VERSION = Gem::Version.new('3.0.18')
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparkle_formation
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.16
4
+ version: 3.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attribute_struct