sparkle_formation 3.0.20 → 3.0.22

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: 96961825cddd3633fa2f084c89a69c5d7150705f
4
- data.tar.gz: c6243723957d182493b5d74ac1068933a15e22e2
3
+ metadata.gz: 5859104b23538649891d59cfbb13e0074559def6
4
+ data.tar.gz: 8cd95968b6fe6a2d959ad896675dd88d32700574
5
5
  SHA512:
6
- metadata.gz: fcddb4dca36acba3b067fe45428270977c3482828f30f6f0374ee8b4ddf2df2a25a71e753f7cfe15c011cdac3a55d6d449246c6c2c68694f72f5ed26f8745e1d
7
- data.tar.gz: aef48b6ab4669fa685f44de8aca587c1912b3a986544e7fe3ae2ca07fe5f5a4d5f0440230690e12bf4afea1f4c151e671b598cff390cfaae92e28d656e3daee1
6
+ metadata.gz: 8ed5c62ff322bb1ca0234c6d46953f8150ff93f22227b3f93ecb35597bdb65908877c441252847f0204c9e5fb6f082731ae39fe2d60b674de7e68642bd16ddf6
7
+ data.tar.gz: b2faee5e3a49d2148798a75763281a134b3a7382e57196576e5a4721b0fa2975e439b21727c746e15469f29c686592531f3efb95930416f6fba8f809dc8e99ae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v3.0.22
2
+ * Add support for non-string like data keys (#217)
3
+ * Customize compile time parameter setting (#218)
4
+ * Add aliasing for Heat and Rackspace to OpenStack
5
+
1
6
  # v3.0.20
2
7
  * Fix nested stack processing. Use value set in place of type check.
3
8
 
@@ -8,6 +8,9 @@ class SparkleFormation
8
8
  # Inheritance error
9
9
  class CircularInheritance < Error; end
10
10
 
11
+ # Found resource improperly constructed
12
+ class InvalidResource < Error; end
13
+
11
14
  # File not found error
12
15
  class NotFound < KeyError
13
16
  attr_reader :name
@@ -29,6 +29,32 @@ class SparkleFormation
29
29
  end
30
30
  end
31
31
 
32
+ # # Create a clone of this instance
33
+ def _clone(*_)
34
+ _klass.new(_fn_name, *_fn_args)
35
+ end
36
+
37
+ # @return [Numeric] hash value for instance
38
+ def hash
39
+ _dump.hash
40
+ end
41
+
42
+ # @return [TrueClass, FalseClass]
43
+ def eql?(_other)
44
+ if(_other.respond_to?(:_dump) && _other.respond_to?(:_parent))
45
+ ::MultiJson.dump(_dump).hash ==
46
+ ::MultiJson.dump(_other._dump).hash &&
47
+ _parent == _other._parent
48
+ else
49
+ false
50
+ end
51
+ end
52
+
53
+ # @return [TrueClass, FalseClass]
54
+ def ==(_other)
55
+ eql?(_other)
56
+ end
57
+
32
58
  # @return [False] functions are never nil
33
59
  def nil?
34
60
  false
@@ -8,6 +8,7 @@ class SparkleFormation
8
8
  autoload :Azure, 'sparkle_formation/provider/azure'
9
9
  autoload :Google, 'sparkle_formation/provider/google'
10
10
  autoload :Heat, 'sparkle_formation/provider/heat'
11
+ autoload :OpenStack, 'sparkle_formation/provider/heat'
11
12
  autoload :Terraform, 'sparkle_formation/provider/terraform'
12
13
 
13
14
  end
@@ -17,6 +17,17 @@ class SparkleFormation
17
17
  {}
18
18
  end
19
19
 
20
+ # Set the current compile_state into the
21
+ # compiled result
22
+ #
23
+ # @param compiled [AttributeStruct]
24
+ # @return [AttributeStruct]
25
+ def set_compiled_state(compiled)
26
+ super
27
+ compiled.outputs.compile_state.type 'String'
28
+ compiled
29
+ end
30
+
20
31
  # Apply deeply nested stacks. This is the new nesting approach and
21
32
  # does not bubble parameters up to the root stack. Parameters are
22
33
  # isolated to the stack resource itself and output mapping is
@@ -159,5 +159,6 @@ class SparkleFormation
159
159
  end
160
160
 
161
161
  end
162
+ OpenStack = Heat
162
163
  end
163
164
  end
@@ -9,6 +9,7 @@ class SparkleFormation
9
9
  autoload :Azure, 'sparkle_formation/sparkle_attribute/azure'
10
10
  autoload :Google, 'sparkle_formation/sparkle_attribute/google'
11
11
  autoload :Heat, 'sparkle_formation/sparkle_attribute/heat'
12
+ autoload :OpenStack, 'sparkle_formation/sparkle_attribute/heat'
12
13
  autoload :Rackspace, 'sparkle_formation/sparkle_attribute/rackspace'
13
14
  autoload :Terraform, 'sparkle_formation/sparkle_attribute/terraform'
14
15
 
@@ -30,6 +31,9 @@ class SparkleFormation
30
31
  unless(result)
31
32
  ::Kernel.raise NameError.new 'Failed to determine current resource name! (Check call location)'
32
33
  end
34
+ if(result.is_a?(::SparkleFormation::FunctionStruct))
35
+ result = result._clone
36
+ end
33
37
  result
34
38
  end
35
39
  alias_method :resource_name!, :_resource_name
@@ -126,6 +126,10 @@ class SparkleFormation
126
126
  resource = _root.resources.set!(r_name)
127
127
  if(resource.nil?)
128
128
  ::Kernel.raise ::SparkleFormation::Error::NotFound::Resource.new(:name => r_name)
129
+ elsif(resource.type.nil?)
130
+ ::Kernel.raise ::SparkleFormation::Error::InvalidResource.new(
131
+ "Resource `#{r_name}` provides no type information."
132
+ )
129
133
  else
130
134
  ::SparkleFormation::FunctionStruct.new(
131
135
  'resourceId',
@@ -10,6 +10,9 @@ class SparkleFormation
10
10
 
11
11
  # Set customized struct behavior
12
12
  def self.included(klass)
13
+ if(klass.const_defined?(:CAMEL_KEYS))
14
+ klass.send(:remove_const, :CAMEL_KEYS)
15
+ end
13
16
  klass.const_set(:CAMEL_KEYS, false)
14
17
  end
15
18
 
@@ -191,6 +194,6 @@ class SparkleFormation
191
194
  alias_method :stack_output!, :_stack_output
192
195
 
193
196
  end
194
-
197
+ OpenStack = Heat
195
198
  end
196
199
  end
@@ -309,12 +309,16 @@ class SparkleFormation
309
309
  if(struct._self.provider_resources && lookup_key = struct._self.provider_resources.registry_key(dynamic_name))
310
310
  _name, _config = *args
311
311
  _config ||= {}
312
- __t_stringish(_name)
313
312
  __t_hashish(_config)
314
- resource_name = [
315
- _name,
316
- _config.fetch(:resource_name_suffix, dynamic_name)
317
- ].compact.join('_').to_sym
313
+ unless(_name.is_a?(SparkleFormation::FunctionStruct))
314
+ __t_stringish(_name)
315
+ resource_name = [
316
+ _name,
317
+ _config.fetch(:resource_name_suffix, dynamic_name)
318
+ ].compact.join('_').to_sym
319
+ else
320
+ resource_name = _name._root
321
+ end
318
322
  _config.delete(:resource_name_suffix)
319
323
  new_resource = struct.resources.set!(resource_name)
320
324
  new_resource.type lookup_key
@@ -736,12 +740,22 @@ class SparkleFormation
736
740
  end
737
741
  end
738
742
  if(compile_state && !compile_state.empty?)
739
- compiled.outputs.compile_state.value MultiJson.dump(compile_state)
743
+ set_compiled_state(compiled)
740
744
  end
741
745
  compiled
742
746
  end
743
747
  end
744
748
 
749
+ # Set the current compile_state into the
750
+ # compiled result
751
+ #
752
+ # @param compiled [AttributeStruct]
753
+ # @return [AttributeStruct]
754
+ def set_compiled_state(compiled)
755
+ compiled.outputs.compile_state.value MultiJson.dump(compile_state)
756
+ compiled
757
+ end
758
+
745
759
  # Clear compiled stack if cached and perform compilation again
746
760
  #
747
761
  # @return [SparkleStruct]
@@ -916,7 +930,8 @@ class SparkleFormation
916
930
  outputs = Smash.new
917
931
  end
918
932
  nested_stacks.each do |nested_stack|
919
- outputs = nested_stack.collect_outputs(:force).merge(outputs)
933
+ n_stack = nested_stack.is_a?(self.class) ? nested_stack : nested_stack._self
934
+ outputs = n_stack.collect_outputs(:force).merge(outputs)
920
935
  end
921
936
  outputs
922
937
  else
@@ -26,6 +26,8 @@ class SparkleFormation
26
26
  include SparkleAttribute
27
27
  include SparkleAttribute::Heat
28
28
  end
29
+ OpenStack = Heat
30
+ Rackspace = Heat
29
31
  # Rackspace specific struct
30
32
  class Rackspace < SparkleStruct
31
33
  include SparkleAttribute
@@ -106,16 +108,26 @@ class SparkleFormation
106
108
  # Override to inspect result value and fetch root if value is a
107
109
  # FunctionStruct
108
110
  def method_missing(sym, *args, &block)
109
- if(sym.to_s.start_with?('_') || sym.to_s.end_with?('!'))
110
- ::Kernel.raise ::NoMethodError.new "Undefined method `#{sym}` for #{_klass.name}"
111
+ if(sym.is_a?(::String) || sym.is_a?(::Symbol))
112
+ if(sym.to_s.start_with?('_') || sym.to_s.end_with?('!'))
113
+ ::Kernel.raise ::NoMethodError.new "Undefined method `#{sym}` for #{_klass.name}"
114
+ end
111
115
  end
112
116
  super(*[sym, *args], &block)
113
- if((s = sym.to_s).end_with?('='))
114
- s.slice!(-1, s.length)
115
- sym = s
117
+ if(sym.is_a?(::String) || sym.is_a?(::Symbol))
118
+ if((s = sym.to_s).end_with?('='))
119
+ s.slice!(-1, s.length)
120
+ sym = s
121
+ end
122
+ sym = _process_key(sym)
123
+ else
124
+ sym = function_bubbler(sym)
116
125
  end
117
- sym = _process_key(sym)
118
126
  @table[sym] = function_bubbler(@table[sym])
127
+ # Always reset parent in case this is a clone
128
+ if(@table[sym].is_a?(::AttributeStruct))
129
+ @table[sym]._parent(self)
130
+ end
119
131
  @table[sym]
120
132
  end
121
133
 
@@ -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.20')
4
+ VERSION = Gem::Version.new('3.0.22')
5
5
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.license = 'Apache-2.0'
12
12
  s.require_path = 'lib'
13
13
  s.required_ruby_version = '>= 2.1'
14
- s.add_runtime_dependency 'attribute_struct', '>= 0.3.0', '< 0.5'
14
+ s.add_runtime_dependency 'attribute_struct', '>= 0.3.5', '< 0.5'
15
15
  s.add_runtime_dependency 'multi_json'
16
16
  s.add_runtime_dependency 'bogo'
17
17
  s.add_development_dependency 'minitest'
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.20
4
+ version: 3.0.22
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-16 00:00:00.000000000 Z
11
+ date: 2017-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attribute_struct
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.3.5
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0.5'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.0
29
+ version: 0.3.5
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0.5'