sparkle_formation 3.0.14 → 3.0.16
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 +4 -0
- data/README.md +2 -1
- data/lib/sparkle_formation/composition.rb +6 -2
- data/lib/sparkle_formation/function_struct.rb +0 -2
- data/lib/sparkle_formation/resources/azure.rb +2 -0
- data/lib/sparkle_formation/resources/google.rb +2 -0
- data/lib/sparkle_formation/resources.rb +12 -6
- data/lib/sparkle_formation/sparkle_attribute/aws.rb +17 -5
- data/lib/sparkle_formation/sparkle_attribute/heat.rb +3 -3
- data/lib/sparkle_formation/sparkle_formation.rb +22 -17
- data/lib/sparkle_formation/sparkle_struct.rb +31 -0
- data/lib/sparkle_formation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff339020395b4fde4837cc5e7deb4001b53ffae
|
4
|
+
data.tar.gz: 0dede473ebcec2f710162af551f0a88da821b8cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7dae3cb305e19d69618541583e6eba0bd472a69db5d0d4d0335cf8469378ac456df131d6c5be9b2b68f2ed01b2394c8aae2c4d8b9021f38cc2e323bb349463a
|
7
|
+
data.tar.gz: f6d7bea2bea0e9ae058e3d5a1769fbe286767f90627484d801111823df9d4ac2ad3b2d99d9298799e79d92693bb52ebf3280eb1dfb4c05601259071724da02f4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -30,8 +30,9 @@ implementation:
|
|
30
30
|
|
31
31
|
* [SparkleFormation Library Documentation](http://www.sparkleformation.io/docs/sparkle_formation/)
|
32
32
|
|
33
|
-
#
|
33
|
+
# Info
|
34
34
|
* Documentation: http://www.sparkleformation.io/docs/sparkle_formation
|
35
35
|
* Repository: https://github.com/sparkleformation/sparkle_formation
|
36
36
|
* Mailing List: https://groups.google.com/forum/#!forum/sparkleformation
|
37
37
|
* IRC: [#sparkleformation @ Freenode](https://webchat.freenode.net/?channels=#sparkleformation)
|
38
|
+
* Gitter: [](https://gitter.im/SparkleFormation/sparkleformation?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -63,6 +63,9 @@ class SparkleFormation
|
|
63
63
|
# @param location [Symbol] :prepend or :append (defaults to :append)
|
64
64
|
# @return [self]
|
65
65
|
def add_component(item, location=:append)
|
66
|
+
unless(item.is_a?(Component) || item.is_a?(Override))
|
67
|
+
raise TypeError.new("Expecting `Component` or `Override` but received `#{item.class}`")
|
68
|
+
end
|
66
69
|
if(item.respond_to?(:key) && component_keys.include?(item.key))
|
67
70
|
# do nothing
|
68
71
|
else
|
@@ -85,6 +88,9 @@ class SparkleFormation
|
|
85
88
|
# @param location [Symbol] :prepend or :append (defaults to :append)
|
86
89
|
# @return [self]
|
87
90
|
def add_override(item, location=:append)
|
91
|
+
unless(item.is_a?(Override))
|
92
|
+
raise TypeError.new("Expecting `Override` but received `#{item.class}`")
|
93
|
+
end
|
88
94
|
case location
|
89
95
|
when :append
|
90
96
|
overrides_list.push(item)
|
@@ -173,7 +179,5 @@ class SparkleFormation
|
|
173
179
|
end
|
174
180
|
|
175
181
|
attr_reader :components_list, :overrides_list
|
176
|
-
|
177
182
|
end
|
178
|
-
|
179
183
|
end
|
@@ -268,8 +268,6 @@ class SparkleFormation
|
|
268
268
|
# FunctionStruct for customized terraform functions
|
269
269
|
class TerraformStruct < FunctionStruct
|
270
270
|
|
271
|
-
SINGLE_ANCHOR = true
|
272
|
-
|
273
271
|
# @return [String] start character(s) used to anchor function call
|
274
272
|
def __anchor_start
|
275
273
|
'${'
|
@@ -8,6 +8,8 @@ class SparkleFormation
|
|
8
8
|
# Azure specific resources collection
|
9
9
|
class Azure < Resources
|
10
10
|
|
11
|
+
# Characters to be removed from supplied key on matching
|
12
|
+
RESOURCE_TYPE_TR = '/._'
|
11
13
|
# String to split for resource namespacing
|
12
14
|
RESOURCE_TYPE_NAMESPACE_SPLITTER = ['.', '/']
|
13
15
|
|
@@ -8,6 +8,8 @@ class SparkleFormation
|
|
8
8
|
# Google specific resources collection
|
9
9
|
class Google < Resources
|
10
10
|
|
11
|
+
# Characters to be removed from supplied key on matching
|
12
|
+
RESOURCE_TYPE_TR = '._'
|
11
13
|
# String to split for resource namespacing
|
12
14
|
RESOURCE_TYPE_NAMESPACE_SPLITTER = ['.']
|
13
15
|
|
@@ -12,7 +12,7 @@ class SparkleFormation
|
|
12
12
|
autoload :Terraform, 'sparkle_formation/resources/terraform'
|
13
13
|
|
14
14
|
# Characters to be removed from supplied key on matching
|
15
|
-
RESOURCE_TYPE_TR = '_'
|
15
|
+
RESOURCE_TYPE_TR = '_:'
|
16
16
|
# String to split for resource namespacing
|
17
17
|
RESOURCE_TYPE_NAMESPACE_SPLITTER = '::'
|
18
18
|
# Property update conditionals
|
@@ -90,11 +90,14 @@ class SparkleFormation
|
|
90
90
|
# @param hash [Hash] metadata information
|
91
91
|
# @return [TrueClass]
|
92
92
|
def register(type, hash)
|
93
|
+
unless(hash.is_a?(Hash))
|
94
|
+
raise TypeError.new("Expecting `Hash` type but received `#{hash.class}`")
|
95
|
+
end
|
93
96
|
unless(class_variable_defined?(:@@registry))
|
94
97
|
@@registry = AttributeStruct.hashish.new
|
95
98
|
end
|
96
99
|
@@registry[base_key] ||= AttributeStruct.hashish.new
|
97
|
-
@@registry[base_key][type] = hash
|
100
|
+
@@registry[base_key][type.to_s] = hash
|
98
101
|
true
|
99
102
|
end
|
100
103
|
|
@@ -102,7 +105,7 @@ class SparkleFormation
|
|
102
105
|
#
|
103
106
|
# @param identifier [String, Symbol] resource identifier
|
104
107
|
# @param key [String, Symbol] specific data
|
105
|
-
# @return [Hashish]
|
108
|
+
# @return [Hashish, NilClass]
|
106
109
|
def resource(identifier, key=nil)
|
107
110
|
res = lookup(identifier)
|
108
111
|
if(key && res)
|
@@ -117,10 +120,13 @@ class SparkleFormation
|
|
117
120
|
# @param json_path_or_hash [String, Hashish] path to files or hash
|
118
121
|
# @return [TrueClass]
|
119
122
|
def load(json_path_or_hash)
|
120
|
-
|
123
|
+
case json_path_or_hash
|
124
|
+
when String
|
121
125
|
content = AttributeStruct.hashish.new(MultiJson.load(File.read(json_path_or_hash)))
|
122
|
-
|
126
|
+
when Hash
|
123
127
|
content = json_path_or_hash
|
128
|
+
else
|
129
|
+
raise TypeError.new("Expecting `String` or `Hash` type but received `#{json_path_or_hash.class}`")
|
124
130
|
end
|
125
131
|
content.each do |type, hash|
|
126
132
|
register(type, hash)
|
@@ -144,7 +150,7 @@ class SparkleFormation
|
|
144
150
|
result = key
|
145
151
|
else
|
146
152
|
o_key = key
|
147
|
-
key = key.to_s.tr(self.const_get(:RESOURCE_TYPE_TR), '') # rubocop:disable Style/RedundantSelf
|
153
|
+
key = key.to_s.downcase.tr(self.const_get(:RESOURCE_TYPE_TR), '') # rubocop:disable Style/RedundantSelf
|
148
154
|
snake_parts = nil
|
149
155
|
result = @@registry[base_key].keys.detect do |ref|
|
150
156
|
ref = ref.downcase
|
@@ -27,16 +27,28 @@ class SparkleFormation
|
|
27
27
|
|
28
28
|
# Split generator
|
29
29
|
#
|
30
|
-
# @param string [String] string to split
|
30
|
+
# @param string [String, Hash] string to split
|
31
31
|
# @param delimiter [String] delimiter to split string
|
32
32
|
# @return [Hash]
|
33
33
|
def _cf_split(string, delimiter)
|
34
|
-
__t_stringish(string)
|
35
|
-
__t_stringish(delimiter)
|
34
|
+
__t_stringish(string) unless string.is_a?(Hash)
|
35
|
+
__t_stringish(delimiter) unless delimiter.is_a?(Hash)
|
36
36
|
{'Fn::Split' => [delimiter, string]}
|
37
37
|
end
|
38
38
|
alias_method :split!, :_cf_split
|
39
39
|
|
40
|
+
# Sub generator
|
41
|
+
#
|
42
|
+
# @param string [String, Hash] string to apply substitution
|
43
|
+
# @param variables [Hash] key value mappings for substitution
|
44
|
+
# @return [Hash]
|
45
|
+
def _cf_sub(string, variables)
|
46
|
+
__t_hashish(variables)
|
47
|
+
{'Fn::Sub' => [string, variables]}
|
48
|
+
end
|
49
|
+
alias_method :_sub, :_cf_sub
|
50
|
+
alias_method :sub!, :_cf_sub
|
51
|
+
|
40
52
|
# Ref generator
|
41
53
|
#
|
42
54
|
# @param thing [String, Symbol] reference name
|
@@ -51,10 +63,10 @@ class SparkleFormation
|
|
51
63
|
|
52
64
|
# ValueImport generator
|
53
65
|
#
|
54
|
-
# @param thing [String,
|
66
|
+
# @param thing [String, Symbol, Hash] value import
|
55
67
|
# @return [Hash]
|
56
68
|
def _cf_value_import(thing)
|
57
|
-
__t_stringish(thing)
|
69
|
+
__t_stringish(thing) unless thing.is_a?(Hash)
|
58
70
|
{'Fn::ImportValue' => __attribute_key(thing)}
|
59
71
|
end
|
60
72
|
alias_method :_import_value, :_cf_value_import
|
@@ -51,7 +51,7 @@ class SparkleFormation
|
|
51
51
|
# @param loc [String]
|
52
52
|
# @return [Hash]
|
53
53
|
def _get_file(loc)
|
54
|
-
|
54
|
+
__t_stringish(loc)
|
55
55
|
{'get_file' => loc}
|
56
56
|
end
|
57
57
|
alias_method :_file, :_get_file
|
@@ -92,7 +92,7 @@ class SparkleFormation
|
|
92
92
|
# @param value [String, Hash] thing to be hashed
|
93
93
|
# @param algorithm [String] algorithm to use (defaults to 'sha512')
|
94
94
|
def _digest(value, algorithm='sha512')
|
95
|
-
|
95
|
+
__t_stringish(algorithm)
|
96
96
|
{'digest' => [algorithm, value]}
|
97
97
|
end
|
98
98
|
alias_method :digest!, :_digest
|
@@ -129,7 +129,7 @@ class SparkleFormation
|
|
129
129
|
# @param idx [Numeric]
|
130
130
|
# @return [Hash]
|
131
131
|
def _str_split(splitter, string, idx=nil)
|
132
|
-
|
132
|
+
__t_stringish(splitter) unless splitter.is_a?(Hash)
|
133
133
|
{'str_split' => [splitter, string, idx].compact}
|
134
134
|
end
|
135
135
|
alias_method :_split, :_str_split
|
@@ -400,22 +400,29 @@ class SparkleFormation
|
|
400
400
|
@component_paths = []
|
401
401
|
if(options[:sparkle_collection])
|
402
402
|
@sparkle = options[:sparkle_collection]
|
403
|
+
if(options[:sparkle])
|
404
|
+
@sparkle.add_sparkle(options[:sparkle])
|
405
|
+
end
|
403
406
|
else
|
404
407
|
@sparkle = SparkleCollection.new
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
408
|
+
if(options[:sparkle])
|
409
|
+
@sparkle.set_root(options[:sparkle])
|
410
|
+
else
|
411
|
+
@sparkle.set_root(
|
412
|
+
Sparkle.new(
|
413
|
+
Smash.new.tap{|h|
|
414
|
+
s_path = options.fetch(:sparkle_path,
|
415
|
+
self.class.custom_paths[:sparkle_path]
|
416
|
+
)
|
417
|
+
if(s_path)
|
418
|
+
h[:root] = s_path
|
419
|
+
else
|
420
|
+
h[:root] = :none
|
421
|
+
end
|
422
|
+
}
|
423
|
+
)
|
417
424
|
)
|
418
|
-
|
425
|
+
end
|
419
426
|
end
|
420
427
|
self.provider = options.fetch(:provider, @parent ? @parent.provider : :aws)
|
421
428
|
if(provider == :aws || !options[:disable_aws_builtins])
|
@@ -687,10 +694,8 @@ class SparkleFormation
|
|
687
694
|
seed_self
|
688
695
|
|
689
696
|
set_compile_time_parameters!
|
690
|
-
if(provider &&
|
691
|
-
|
692
|
-
struct_class = Class.new(SparkleStruct)
|
693
|
-
struct_class.include(const)
|
697
|
+
if(provider && SparkleStruct.const_defined?(camel(provider)))
|
698
|
+
struct_class = SparkleStruct.const_get(camel(provider))
|
694
699
|
struct_name = [SparkleStruct.name, camel(provider)].join('::')
|
695
700
|
struct_class.define_singleton_method(:name){ struct_name }
|
696
701
|
struct_class.define_singleton_method(:to_s){ struct_name }
|
@@ -6,6 +6,37 @@ class SparkleFormation
|
|
6
6
|
# SparkleFormation customized AttributeStruct
|
7
7
|
class SparkleStruct < AttributeStruct
|
8
8
|
|
9
|
+
# AWS specific struct
|
10
|
+
class Aws < SparkleStruct
|
11
|
+
include SparkleAttribute
|
12
|
+
include SparkleAttribute::Aws
|
13
|
+
end
|
14
|
+
# Azure specific struct
|
15
|
+
class Azure < SparkleStruct
|
16
|
+
include SparkleAttribute
|
17
|
+
include SparkleAttribute::Azure
|
18
|
+
end
|
19
|
+
# Google specific struct
|
20
|
+
class Google < SparkleStruct
|
21
|
+
include SparkleAttribute
|
22
|
+
include SparkleAttribute::Google
|
23
|
+
end
|
24
|
+
# Heat specific struct
|
25
|
+
class Heat < SparkleStruct
|
26
|
+
include SparkleAttribute
|
27
|
+
include SparkleAttribute::Heat
|
28
|
+
end
|
29
|
+
# Rackspace specific struct
|
30
|
+
class Rackspace < SparkleStruct
|
31
|
+
include SparkleAttribute
|
32
|
+
include SparkleAttribute::Rackspace
|
33
|
+
end
|
34
|
+
# Terraform specific struct
|
35
|
+
class Terraform < SparkleStruct
|
36
|
+
include SparkleAttribute
|
37
|
+
include SparkleAttribute::Terraform
|
38
|
+
end
|
39
|
+
|
9
40
|
include ::SparkleFormation::SparkleAttribute
|
10
41
|
# @!parse include ::SparkleFormation::SparkleAttribute
|
11
42
|
include ::SparkleFormation::Utils::TypeCheckers
|
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.
|
4
|
+
version: 3.0.16
|
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-
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attribute_struct
|