sparkle_formation 3.0.26 → 3.0.28

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.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +6 -0
  3. data/lib/sparkle_formation/composition.rb +17 -17
  4. data/lib/sparkle_formation/error.rb +2 -5
  5. data/lib/sparkle_formation/function_struct.rb +27 -31
  6. data/lib/sparkle_formation/provider/aws.rb +32 -31
  7. data/lib/sparkle_formation/provider/azure.rb +18 -19
  8. data/lib/sparkle_formation/provider/google.rb +20 -22
  9. data/lib/sparkle_formation/provider/heat.rb +17 -17
  10. data/lib/sparkle_formation/provider/terraform.rb +14 -15
  11. data/lib/sparkle_formation/provider.rb +0 -2
  12. data/lib/sparkle_formation/resources/aws.rb +129 -149
  13. data/lib/sparkle_formation/resources/aws_resources.json +9208 -5542
  14. data/lib/sparkle_formation/resources/azure.rb +2 -5
  15. data/lib/sparkle_formation/resources/azure_resources.json +12367 -2901
  16. data/lib/sparkle_formation/resources/google.rb +1 -4
  17. data/lib/sparkle_formation/resources/heat.rb +0 -4
  18. data/lib/sparkle_formation/resources/heat_resources.json +2616 -2062
  19. data/lib/sparkle_formation/resources/rackspace.rb +0 -4
  20. data/lib/sparkle_formation/resources/terraform.rb +2 -6
  21. data/lib/sparkle_formation/resources.rb +20 -24
  22. data/lib/sparkle_formation/sparkle.rb +56 -66
  23. data/lib/sparkle_formation/sparkle_attribute/aws.rb +61 -34
  24. data/lib/sparkle_formation/sparkle_attribute/azure.rb +12 -8
  25. data/lib/sparkle_formation/sparkle_attribute/google.rb +18 -15
  26. data/lib/sparkle_formation/sparkle_attribute/heat.rb +22 -7
  27. data/lib/sparkle_formation/sparkle_attribute/rackspace.rb +0 -2
  28. data/lib/sparkle_formation/sparkle_attribute/terraform.rb +11 -5
  29. data/lib/sparkle_formation/sparkle_attribute.rb +13 -7
  30. data/lib/sparkle_formation/sparkle_collection/rainbow.rb +5 -7
  31. data/lib/sparkle_formation/sparkle_collection.rb +13 -15
  32. data/lib/sparkle_formation/sparkle_formation.rb +116 -112
  33. data/lib/sparkle_formation/sparkle_struct.rb +30 -24
  34. data/lib/sparkle_formation/translation/heat.rb +57 -58
  35. data/lib/sparkle_formation/translation/rackspace.rb +48 -49
  36. data/lib/sparkle_formation/translation.rb +34 -37
  37. data/lib/sparkle_formation/utils.rb +6 -13
  38. data/lib/sparkle_formation/version.rb +1 -1
  39. data/sparkle_formation.gemspec +1 -1
  40. metadata +9 -9
@@ -17,6 +17,7 @@ class SparkleFormation
17
17
  __t_stringish(v_name)
18
18
  res = ::SparkleFormation::TerraformStruct.new('var').set!(__attribute_key(v_name))
19
19
  end
20
+
20
21
  alias_method :var!, :_var
21
22
  alias_method :parameter!, :_var
22
23
 
@@ -24,23 +25,27 @@ class SparkleFormation
24
25
  __t_stringish(p_name)
25
26
  ::SparkleFormation::TerraformStruct.new('path').set!(__attribute_key(p_name))
26
27
  end
28
+
27
29
  alias_method :path!, :_path
28
30
 
29
31
  def _module(m_name)
30
32
  __t_stringish(m_name)
31
33
  ::SparkleFormation::TerraformStruct.new('module').set!(__attribute_key(m_name))
32
34
  end
35
+
33
36
  alias_method :module!, :_module
34
37
 
35
38
  def _terraform_self(s_name)
36
39
  __t_stringish(s_name)
37
40
  ::SparkleFormation::TerraformStruct.new('self').set!(__attribute_key(s_name))
38
41
  end
42
+
39
43
  alias_method :self!, :_terraform_self
40
44
 
41
45
  def _terraform_lookup(*args)
42
46
  ::SparkleFormation::TerraformStruct.new('lookup', *args)
43
47
  end
48
+
44
49
  alias_method :lookup!, :_terraform_lookup
45
50
 
46
51
  # TODO: Add resource checking before returning structure
@@ -49,6 +54,7 @@ class SparkleFormation
49
54
  r_name = __resource_lookup(r_name)
50
55
  ::SparkleFormation::TerraformStruct.new(r_name)
51
56
  end
57
+
52
58
  alias_method :resource!, :_resource
53
59
 
54
60
  TERRAFORM_INTRINSIC_FUNCTIONS = [
@@ -83,7 +89,7 @@ class SparkleFormation
83
89
  'sort',
84
90
  'split',
85
91
  'trimspace',
86
- 'upper'
92
+ 'upper',
87
93
  ]
88
94
 
89
95
  # NOTE: Alias implementation disabled due to Ruby 2.3 __callee__ bug
@@ -114,7 +120,7 @@ class SparkleFormation
114
120
 
115
121
  def __resource_lookup(name)
116
122
  resource = root!.resources[name]
117
- if(resource.nil?)
123
+ if resource.nil?
118
124
  name
119
125
  else
120
126
  "#{resource.type}.#{name}"
@@ -131,8 +137,9 @@ class SparkleFormation
131
137
  # @return [Array<String>]
132
138
  # @note this will directly modify the struct at its current context to inject depends on structure
133
139
  def _depends_on(*args)
134
- _set('depends_on', [args].flatten.compact.map{|s| __attribute_key(s) })
140
+ _set('depends_on', [args].flatten.compact.map { |s| __attribute_key(s) })
135
141
  end
142
+
136
143
  alias_method :depends_on!, :_depends_on
137
144
 
138
145
  # Reference output value from nested stack
@@ -143,9 +150,8 @@ class SparkleFormation
143
150
  def _stack_output(stack_name, output_name)
144
151
  _module(stack_name)._set(output_name)
145
152
  end
146
- alias_method :stack_output!, :_stack_output
147
153
 
154
+ alias_method :stack_output!, :_stack_output
148
155
  end
149
-
150
156
  end
151
157
  end
@@ -4,7 +4,6 @@ class SparkleFormation
4
4
 
5
5
  # Provides template helper methods
6
6
  module SparkleAttribute
7
-
8
7
  autoload :Aws, 'sparkle_formation/sparkle_attribute/aws'
9
8
  autoload :Azure, 'sparkle_formation/sparkle_attribute/azure'
10
9
  autoload :Google, 'sparkle_formation/sparkle_attribute/google'
@@ -18,8 +17,8 @@ class SparkleFormation
18
17
  # @return [String]
19
18
  def _resource_name
20
19
  result = nil
21
- if(_parent)
22
- if(_parent._parent == _root)
20
+ if _parent
21
+ if _parent._parent == _root
23
22
  result = _parent._data.detect do |r_name, r_value|
24
23
  r_value == self
25
24
  end
@@ -28,14 +27,15 @@ class SparkleFormation
28
27
  result = _parent._resource_name
29
28
  end
30
29
  end
31
- unless(result)
30
+ unless result
32
31
  ::Kernel.raise NameError.new 'Failed to determine current resource name! (Check call location)'
33
32
  end
34
- if(result.is_a?(::SparkleFormation::FunctionStruct))
33
+ if result.is_a?(::SparkleFormation::FunctionStruct)
35
34
  result = result._clone
36
35
  end
37
36
  result
38
37
  end
38
+
39
39
  alias_method :resource_name!, :_resource_name
40
40
 
41
41
  # Execute system command
@@ -45,6 +45,7 @@ class SparkleFormation
45
45
  def _system(command)
46
46
  ::Kernel.send('`', command)
47
47
  end
48
+
48
49
  alias_method :system!, :_system
49
50
 
50
51
  # @overload _puts(obj, ...)
@@ -55,6 +56,7 @@ class SparkleFormation
55
56
  def _puts(*args)
56
57
  $stdout.puts(*args)
57
58
  end
59
+
58
60
  alias_method :puts!, :_puts
59
61
 
60
62
  # Raise an exception
@@ -62,6 +64,7 @@ class SparkleFormation
62
64
  def _raise(*args)
63
65
  ::Kernel.raise(*args)
64
66
  end
67
+
65
68
  alias_method :raise!, :_raise
66
69
 
67
70
  # @overload _method(sym)
@@ -73,6 +76,7 @@ class SparkleFormation
73
76
  def _method(*args)
74
77
  ::Kernel.instance_method(:method).bind(self).call(*args)
75
78
  end
79
+
76
80
  alias_method :method!, :_method
77
81
 
78
82
  # @overload _dynamic(resource_type, custom_name, options={})
@@ -97,6 +101,7 @@ class SparkleFormation
97
101
  def _dynamic(name, *args, &block)
98
102
  SparkleFormation.insert(name, self, *args, &block)
99
103
  end
104
+
100
105
  alias_method :dynamic!, :_dynamic
101
106
 
102
107
  # @overload _registry(name)
@@ -114,6 +119,7 @@ class SparkleFormation
114
119
  def _registry(name, *args)
115
120
  SparkleFormation.registry(name, self, *args)
116
121
  end
122
+
117
123
  alias_method :registry!, :_registry
118
124
 
119
125
  # @overload _nest(template, *names, options={})
@@ -133,6 +139,7 @@ class SparkleFormation
133
139
  def _nest(template, *args, &block)
134
140
  SparkleFormation.nest(template, self, *args, &block)
135
141
  end
142
+
136
143
  alias_method :nest!, :_nest
137
144
 
138
145
  # Format the provided key. If symbol type is provided
@@ -142,12 +149,11 @@ class SparkleFormation
142
149
  # @param key [String, Symbol] given key
143
150
  # @return [String] formatted key
144
151
  def __attribute_key(key)
145
- if(key.is_a?(::Symbol) || key.is_a?(::String))
152
+ if key.is_a?(::Symbol) || key.is_a?(::String)
146
153
  _process_key(key, key.is_a?(::Symbol) ? :force : nil)
147
154
  else
148
155
  key
149
156
  end
150
157
  end
151
-
152
158
  end
153
159
  end
@@ -2,7 +2,6 @@ require 'sparkle_formation'
2
2
  require 'forwardable'
3
3
 
4
4
  class SparkleFormation
5
-
6
5
  class SparkleCollection
7
6
 
8
7
  # Contains a layered number of a specific item defined via
@@ -15,7 +14,7 @@ class SparkleFormation
15
14
  VALID_TYPES = [
16
15
  :template,
17
16
  :component,
18
- :dynamic
17
+ :dynamic,
19
18
  ].freeze
20
19
 
21
20
  extend Forwardable
@@ -34,7 +33,7 @@ class SparkleFormation
34
33
  # @param type [String, Symbol] type of item
35
34
  # @return [self]
36
35
  def initialize(name, type)
37
- unless(VALID_TYPES.include?(type.to_sym))
36
+ unless VALID_TYPES.include?(type.to_sym)
38
37
  raise ArgumentError.new "Invalid type provdied for Rainbow instance `#{type}`"
39
38
  end
40
39
  @name = name.to_s
@@ -47,7 +46,7 @@ class SparkleFormation
47
46
  # @param item [Hash]
48
47
  # @return [self]
49
48
  def add_layer(item)
50
- unless(item.is_a?(Hash))
49
+ unless item.is_a?(Hash)
51
50
  raise TypeError.new "Expecting type `Hash` but received type `#{item.class}`"
52
51
  end
53
52
  spectrum << item.to_smash
@@ -59,7 +58,7 @@ class SparkleFormation
59
58
  # @param idx [Integer]
60
59
  # @return [Hash]
61
60
  def layer_at(idx)
62
- if(idx <= spectrum.size)
61
+ if idx <= spectrum.size
63
62
  spectrum.at(idx)
64
63
  else
65
64
  raise KeyError.new "Invalid layer requested for #{type} - #{name} (index: #{idx})"
@@ -74,7 +73,7 @@ class SparkleFormation
74
73
  def monochrome
75
74
  Array.new.tap do |result|
76
75
  spectrum.each do |item|
77
- unless(item.get(:args, :layering).to_s == 'merge')
76
+ unless item.get(:args, :layering).to_s == 'merge'
78
77
  result.clear
79
78
  end
80
79
  result << item
@@ -87,6 +86,5 @@ class SparkleFormation
87
86
  spectrum.last || {}
88
87
  end
89
88
  end
90
-
91
89
  end
92
90
  end
@@ -5,7 +5,6 @@ class SparkleFormation
5
5
  # @todo add unmemoize behavior on collection modification to prevent
6
6
  # leak on long running processes with long lasting collections
7
7
  class SparkleCollection < Sparkle
8
-
9
8
  autoload :Rainbow, 'sparkle_formation/sparkle_collection/rainbow'
10
9
 
11
10
  # @return [Symbol] provider
@@ -16,7 +15,7 @@ class SparkleFormation
16
15
  # @param args [Hash]
17
16
  # @option args [Symbol, String] :provider name of default provider
18
17
  # @return [self]
19
- def initialize(args={})
18
+ def initialize(args = {})
20
19
  @provider = Bogo::Utility.snake(args.to_smash.fetch(:provider, 'aws')).to_sym
21
20
  @root = nil
22
21
  @sparkles = []
@@ -46,11 +45,11 @@ class SparkleFormation
46
45
  #
47
46
  # @param sparkle [Sparkle]
48
47
  # @return [self]
49
- def add_sparkle(sparkle, precedence=:high)
50
- unless(sparkle.is_a?(Sparkle))
48
+ def add_sparkle(sparkle, precedence = :high)
49
+ unless sparkle.is_a?(Sparkle)
51
50
  raise TypeError.new "Expected type `SparkleFormation::Sparkle` but received `#{sparkle.class}`!"
52
51
  end
53
- if(precedence == :high)
52
+ if precedence == :high
54
53
  @sparkles.push(sparkle).uniq!
55
54
  else
56
55
  @sparkles.unshift(sparkle).uniq!
@@ -89,7 +88,7 @@ class SparkleFormation
89
88
  sparkles.each do |sprkl|
90
89
  sprkl.components.each_pair do |c_provider, c_info|
91
90
  c_info.each_pair do |c_name, c_value|
92
- unless(hsh.get(c_provider, c_name))
91
+ unless hsh.get(c_provider, c_name)
93
92
  hsh.set(c_provider, c_name, Rainbow.new(c_name, :component))
94
93
  end
95
94
  hsh.get(c_provider, c_name).add_layer(c_value)
@@ -107,7 +106,7 @@ class SparkleFormation
107
106
  sparkles.each do |sprkl|
108
107
  sprkl.dynamics.each_pair do |c_provider, c_info|
109
108
  c_info.each_pair do |c_name, c_value|
110
- unless(hsh.get(c_provider, c_name))
109
+ unless hsh.get(c_provider, c_name)
111
110
  hsh.set(c_provider, c_name, Rainbow.new(c_name, :dynamic))
112
111
  end
113
112
  hsh.get(c_provider, c_name).add_layer(c_value)
@@ -136,7 +135,7 @@ class SparkleFormation
136
135
  sparkles.each do |sprkl|
137
136
  sprkl.templates.each_pair do |c_provider, c_info|
138
137
  c_info.each_pair do |c_name, c_value|
139
- unless(hsh.get(c_provider, c_name))
138
+ unless hsh.get(c_provider, c_name)
140
139
  hsh.set(c_provider, c_name, Rainbow.new(c_name, :template))
141
140
  end
142
141
  hsh.get(c_provider, c_name).add_layer(c_value)
@@ -154,29 +153,29 @@ class SparkleFormation
154
153
  # @param target_provider [String, Symbol] restrict to provider
155
154
  # @return [Smash] requested item
156
155
  # @raises [NameError, Error::NotFound]
157
- def get(type, name, target_provider=nil)
156
+ def get(type, name, target_provider = nil)
158
157
  type_name = Sparkle::TYPES[type.to_s]
159
- unless(type_name)
158
+ unless type_name
160
159
  raise ArgumentError.new "Unknown file type requested from collection `#{type}`"
161
160
  end
162
161
  result = nil
163
162
  error = nil
164
- unless(target_provider)
163
+ unless target_provider
165
164
  target_provider = provider
166
165
  end
167
166
  result = send(type_name).get(target_provider, name)
168
- if(result.nil? && type_name == 'templates')
167
+ if result.nil? && type_name == 'templates'
169
168
  t_direct = sparkles.map do |pack|
170
169
  begin
171
170
  pack.get(:template, name, target_provider)
172
171
  rescue Error::NotFound
173
172
  end
174
173
  end.compact.last
175
- if(t_direct)
174
+ if t_direct
176
175
  result = send(type_name).get(target_provider, t_direct[:name])
177
176
  end
178
177
  end
179
- unless(result)
178
+ unless result
180
179
  error_klass = Error::NotFound.const_get(
181
180
  Bogo::Utility.camel(type)
182
181
  )
@@ -200,6 +199,5 @@ class SparkleFormation
200
199
  end
201
200
  end.checksum
202
201
  end
203
-
204
202
  end
205
203
  end