sparkle_formation 3.0.30 → 3.0.32
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 +3 -0
- data/lib/sparkle_formation.rb +23 -23
- data/lib/sparkle_formation/aws.rb +1 -1
- data/lib/sparkle_formation/composition.rb +7 -7
- data/lib/sparkle_formation/error.rb +2 -2
- data/lib/sparkle_formation/function_struct.rb +22 -22
- data/lib/sparkle_formation/provider.rb +7 -7
- data/lib/sparkle_formation/provider/aws.rb +28 -28
- data/lib/sparkle_formation/provider/azure.rb +7 -7
- data/lib/sparkle_formation/provider/google.rb +16 -16
- data/lib/sparkle_formation/provider/heat.rb +6 -6
- data/lib/sparkle_formation/provider/terraform.rb +7 -7
- data/lib/sparkle_formation/resources.rb +18 -18
- data/lib/sparkle_formation/resources/aws.rb +216 -126
- data/lib/sparkle_formation/resources/aws_resources.json +3463 -1601
- data/lib/sparkle_formation/resources/azure.rb +6 -6
- data/lib/sparkle_formation/resources/google.rb +7 -7
- data/lib/sparkle_formation/resources/heat.rb +2 -2
- data/lib/sparkle_formation/resources/rackspace.rb +2 -2
- data/lib/sparkle_formation/resources/terraform.rb +6 -6
- data/lib/sparkle_formation/sparkle.rb +32 -32
- data/lib/sparkle_formation/sparkle_attribute.rb +10 -10
- data/lib/sparkle_formation/sparkle_attribute/aws.rb +30 -30
- data/lib/sparkle_formation/sparkle_attribute/azure.rb +39 -39
- data/lib/sparkle_formation/sparkle_attribute/google.rb +19 -19
- data/lib/sparkle_formation/sparkle_attribute/heat.rb +16 -16
- data/lib/sparkle_formation/sparkle_attribute/rackspace.rb +1 -1
- data/lib/sparkle_formation/sparkle_attribute/terraform.rb +41 -41
- data/lib/sparkle_formation/sparkle_collection.rb +4 -4
- data/lib/sparkle_formation/sparkle_collection/rainbow.rb +3 -3
- data/lib/sparkle_formation/sparkle_formation.rb +31 -31
- data/lib/sparkle_formation/sparkle_struct.rb +5 -5
- data/lib/sparkle_formation/translation.rb +32 -32
- data/lib/sparkle_formation/translation/heat.rb +126 -126
- data/lib/sparkle_formation/translation/rackspace.rb +118 -118
- data/lib/sparkle_formation/utils.rb +5 -5
- data/lib/sparkle_formation/version.rb +1 -1
- data/sparkle_formation.gemspec +1 -1
- metadata +7 -7
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "sparkle_formation"
|
2
2
|
|
3
3
|
class SparkleFormation
|
4
4
|
|
@@ -14,12 +14,12 @@ class SparkleFormation
|
|
14
14
|
# @param hash [Hash] template dump
|
15
15
|
# @return [Hash]
|
16
16
|
def self.resources_formatter(hash)
|
17
|
-
if hash.key?(
|
18
|
-
resources = hash.delete(
|
19
|
-
hash[
|
17
|
+
if hash.key?("resources") && !hash["resources"].is_a?(Array)
|
18
|
+
resources = hash.delete("resources")
|
19
|
+
hash["resources"] = Array.new
|
20
20
|
resources.each do |r_name, r_contents|
|
21
|
-
hash[
|
22
|
-
r_contents.merge(
|
21
|
+
hash["resources"].push(
|
22
|
+
r_contents.merge("name" => r_name)
|
23
23
|
)
|
24
24
|
end
|
25
25
|
end
|
@@ -48,33 +48,33 @@ class SparkleFormation
|
|
48
48
|
|
49
49
|
# Valid azure builtin functions
|
50
50
|
AZURE_FUNCTIONS = [
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
51
|
+
"add",
|
52
|
+
"copyIndex",
|
53
|
+
"div",
|
54
|
+
"int",
|
55
|
+
"length",
|
56
|
+
"mod",
|
57
|
+
"mul",
|
58
|
+
"sub",
|
59
|
+
"base64",
|
60
|
+
"concat",
|
61
|
+
"padLeft",
|
62
|
+
"replace",
|
63
|
+
"split",
|
64
|
+
"string",
|
65
|
+
"substring",
|
66
|
+
"toLower",
|
67
|
+
"toUpper",
|
68
|
+
"trim",
|
69
|
+
"uniqueString",
|
70
|
+
"uri",
|
71
|
+
"deployment",
|
72
|
+
"parameters",
|
73
|
+
"listKeys",
|
74
|
+
"providers",
|
75
|
+
"reference",
|
76
|
+
"resourceGroup",
|
77
|
+
"subscription",
|
78
78
|
]
|
79
79
|
|
80
80
|
# NOTE: Alias implementation disabled due to Ruby 2.3 __callee__ bug
|
@@ -85,7 +85,7 @@ class SparkleFormation
|
|
85
85
|
# @return [SparkleFormation::FunctionStruct]
|
86
86
|
def _fn_format(*args)
|
87
87
|
src = ::Kernel.__callee__.to_s
|
88
|
-
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/,
|
88
|
+
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/, ""), false)
|
89
89
|
::SparkleFormation::FunctionStruct.new(src, *args)
|
90
90
|
end
|
91
91
|
|
@@ -97,7 +97,7 @@ class SparkleFormation
|
|
97
97
|
|
98
98
|
define_method("_#{f_name}".to_sym) do |*args|
|
99
99
|
src = ::Kernel.__callee__.to_s
|
100
|
-
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/,
|
100
|
+
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/, ""), false)
|
101
101
|
::SparkleFormation::FunctionStruct.new(src, *args)
|
102
102
|
end
|
103
103
|
alias_method "#{f_name}!".to_sym, "_#{f_name}".to_sym
|
@@ -107,7 +107,7 @@ class SparkleFormation
|
|
107
107
|
#
|
108
108
|
# @return [SparkleFormation::AzureVariableStruct]
|
109
109
|
def _variables(*args)
|
110
|
-
x = ::SparkleFormation::AzureVariableStruct.new(
|
110
|
+
x = ::SparkleFormation::AzureVariableStruct.new("variables", *args)
|
111
111
|
x._fn_context = self
|
112
112
|
x
|
113
113
|
end
|
@@ -122,7 +122,7 @@ class SparkleFormation
|
|
122
122
|
# @return [FunctionStruct]
|
123
123
|
def _resource_id(*args)
|
124
124
|
if args.size > 1
|
125
|
-
::SparkleFormation::FunctionStruct.new(
|
125
|
+
::SparkleFormation::FunctionStruct.new("resourceId", *args)
|
126
126
|
else
|
127
127
|
r_name = args.first
|
128
128
|
resource = _root.resources.set!(r_name)
|
@@ -134,7 +134,7 @@ class SparkleFormation
|
|
134
134
|
)
|
135
135
|
else
|
136
136
|
::SparkleFormation::FunctionStruct.new(
|
137
|
-
|
137
|
+
"resourceId",
|
138
138
|
resource.type,
|
139
139
|
resource.resource_name!
|
140
140
|
)
|
@@ -161,7 +161,7 @@ class SparkleFormation
|
|
161
161
|
if resource.nil?
|
162
162
|
::Kernel.raise ::SparkleFormation::Error::NotFound::Resource.new(:name => item)
|
163
163
|
else
|
164
|
-
[resource.type, resource.resource_name!].join(
|
164
|
+
[resource.type, resource.resource_name!].join("/")
|
165
165
|
end
|
166
166
|
else
|
167
167
|
item
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "zlib"
|
2
|
+
require "sparkle_formation"
|
3
3
|
|
4
4
|
class SparkleFormation
|
5
5
|
module SparkleAttribute
|
6
6
|
|
7
7
|
# Google specific helper implementations
|
8
8
|
module Google
|
9
|
-
CHARACTER_COLLECTION = (
|
9
|
+
CHARACTER_COLLECTION = ("a".."z").to_a
|
10
10
|
|
11
11
|
def self.included(klass)
|
12
12
|
klass.const_set(:CAMEL_STYLE, :no_leading)
|
@@ -16,23 +16,23 @@ class SparkleFormation
|
|
16
16
|
result = _non_google_attribute_struct_dump
|
17
17
|
if _parent.nil?
|
18
18
|
sparkle_root = {}
|
19
|
-
if result.key?(
|
20
|
-
resources = result.delete(
|
21
|
-
sparkle_root = (resources.delete(_self.name) || {}).fetch(
|
22
|
-
result[
|
23
|
-
r_content.merge(
|
19
|
+
if result.key?("resources") && result["resources"].is_a?(Hash)
|
20
|
+
resources = result.delete("resources") || {}
|
21
|
+
sparkle_root = (resources.delete(_self.name) || {}).fetch("properties", {})
|
22
|
+
result["resources"] = resources.map do |r_name, r_content|
|
23
|
+
r_content.merge("name" => r_name)
|
24
24
|
end
|
25
|
-
outputs = result.delete(
|
26
|
-
result[
|
27
|
-
o_content.merge(
|
25
|
+
outputs = result.delete("outputs") || {}
|
26
|
+
result["outputs"] = outputs.map do |o_name, o_content|
|
27
|
+
o_content.merge("name" => o_name)
|
28
28
|
end
|
29
29
|
if _self.parent.nil?
|
30
30
|
result = {
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
"resources" => [{
|
32
|
+
"name" => _self.name,
|
33
|
+
"type" => _self.stack_resource_type,
|
34
|
+
"properties" => {
|
35
|
+
"stack" => result,
|
36
36
|
}.merge(sparkle_root),
|
37
37
|
}],
|
38
38
|
}
|
@@ -57,7 +57,7 @@ class SparkleFormation
|
|
57
57
|
# @note generate unique names using the `:sparkle_unique` argument
|
58
58
|
def _google_dynamic!(name, *args, &block)
|
59
59
|
if args.delete(:sparkle_unique)
|
60
|
-
seed = Zlib.crc32(_self.root_path.map(&:name).join(
|
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(
|
@@ -70,7 +70,7 @@ class SparkleFormation
|
|
70
70
|
args.push(config_hash)
|
71
71
|
end
|
72
72
|
config_hash[:resource_name_suffix] = "-#{suffix}"
|
73
|
-
args[0] = args.first.to_s.tr(
|
73
|
+
args[0] = args.first.to_s.tr("_", "-").downcase
|
74
74
|
end
|
75
75
|
_non_google_dynamic!(name, *args, &block)
|
76
76
|
end
|
@@ -85,7 +85,7 @@ class SparkleFormation
|
|
85
85
|
if _root.resources.set!(r_name).nil?
|
86
86
|
::Kernel.raise ::SparkleFormation::Error::NotFound::Resource.new(:name => r_name)
|
87
87
|
else
|
88
|
-
::SparkleFormation::GoogleStruct.new(
|
88
|
+
::SparkleFormation::GoogleStruct.new("ref").set!(__attribute_key(r_name))
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "sparkle_formation"
|
2
2
|
|
3
3
|
class SparkleFormation
|
4
4
|
|
@@ -26,7 +26,7 @@ class SparkleFormation
|
|
26
26
|
args = args.map do |thing|
|
27
27
|
__attribute_key(thing)
|
28
28
|
end
|
29
|
-
{
|
29
|
+
{"get_attr" => args}
|
30
30
|
end
|
31
31
|
|
32
32
|
alias_method :_attr, :_get_attr
|
@@ -45,7 +45,7 @@ class SparkleFormation
|
|
45
45
|
unless args.size == 1
|
46
46
|
args = [args]
|
47
47
|
end
|
48
|
-
{
|
48
|
+
{"list_join" => [options[:options][:delimiter] || "", *args]}
|
49
49
|
end
|
50
50
|
|
51
51
|
alias_method :_join, :_list_join
|
@@ -57,7 +57,7 @@ class SparkleFormation
|
|
57
57
|
# @return [Hash]
|
58
58
|
def _get_file(loc)
|
59
59
|
__t_stringish(loc)
|
60
|
-
{
|
60
|
+
{"get_file" => loc}
|
61
61
|
end
|
62
62
|
|
63
63
|
alias_method :_file, :_get_file
|
@@ -77,7 +77,7 @@ class SparkleFormation
|
|
77
77
|
args = args.map do |thing|
|
78
78
|
__attribute_key(thing)
|
79
79
|
end
|
80
|
-
{
|
80
|
+
{"get_param" => args.size == 1 ? args.first : args}
|
81
81
|
end
|
82
82
|
|
83
83
|
alias_method :_param, :_get_param
|
@@ -89,7 +89,7 @@ class SparkleFormation
|
|
89
89
|
# @return [Hash]
|
90
90
|
def _get_resource(r_name)
|
91
91
|
__t_stringish(r_name)
|
92
|
-
{
|
92
|
+
{"get_resource" => __attribute_key(r_name)}
|
93
93
|
end
|
94
94
|
|
95
95
|
alias_method :_resource, :_get_resource
|
@@ -99,9 +99,9 @@ class SparkleFormation
|
|
99
99
|
#
|
100
100
|
# @param value [String, Hash] thing to be hashed
|
101
101
|
# @param algorithm [String] algorithm to use (defaults to 'sha512')
|
102
|
-
def _digest(value, algorithm =
|
102
|
+
def _digest(value, algorithm = "sha512")
|
103
103
|
__t_stringish(algorithm)
|
104
|
-
{
|
104
|
+
{"digest" => [algorithm, value]}
|
105
105
|
end
|
106
106
|
|
107
107
|
alias_method :digest!, :_digest
|
@@ -112,7 +112,7 @@ class SparkleFormation
|
|
112
112
|
# @return [Hash]
|
113
113
|
def _resource_facade(type)
|
114
114
|
__t_stringish(type)
|
115
|
-
{
|
115
|
+
{"resource_facade" => type}
|
116
116
|
end
|
117
117
|
|
118
118
|
alias_method :_facade, :_resource_facade
|
@@ -127,7 +127,7 @@ class SparkleFormation
|
|
127
127
|
def _str_replace(template, params)
|
128
128
|
__t_stringish(template)
|
129
129
|
__t_hashish(params)
|
130
|
-
{
|
130
|
+
{"str_replace" => {"template" => template, "params" => params}}
|
131
131
|
end
|
132
132
|
|
133
133
|
alias_method :_replace, :_str_replace
|
@@ -141,7 +141,7 @@ class SparkleFormation
|
|
141
141
|
# @return [Hash]
|
142
142
|
def _str_split(splitter, string, idx = nil)
|
143
143
|
__t_stringish(splitter) unless splitter.is_a?(Hash)
|
144
|
-
{
|
144
|
+
{"str_split" => [splitter, string, idx].compact}
|
145
145
|
end
|
146
146
|
|
147
147
|
alias_method :_split, :_str_split
|
@@ -153,28 +153,28 @@ class SparkleFormation
|
|
153
153
|
# @param hash2 [Hash] item to merge
|
154
154
|
# @return [Hash]
|
155
155
|
def _map_merge(*args)
|
156
|
-
{
|
156
|
+
{"map_merge" => args}
|
157
157
|
end
|
158
158
|
|
159
159
|
alias_method :map_merge!, :_map_merge
|
160
160
|
|
161
161
|
# @return [Hash]
|
162
162
|
def _stack_id
|
163
|
-
_get_param(
|
163
|
+
_get_param("OS::stack_id")
|
164
164
|
end
|
165
165
|
|
166
166
|
alias_method :stack_id!, :_stack_id
|
167
167
|
|
168
168
|
# @return [Hash]
|
169
169
|
def _stack_name
|
170
|
-
_get_param(
|
170
|
+
_get_param("OS::stack_name")
|
171
171
|
end
|
172
172
|
|
173
173
|
alias_method :stack_name!, :_stack_name
|
174
174
|
|
175
175
|
# @return [Hash]
|
176
176
|
def _project_id
|
177
|
-
_get_param(
|
177
|
+
_get_param("OS::project_id")
|
178
178
|
end
|
179
179
|
|
180
180
|
alias_method :project_id!, :_project_id
|
@@ -189,7 +189,7 @@ class SparkleFormation
|
|
189
189
|
# @return [Array<String>]
|
190
190
|
# @note this will directly modify the struct at its current context to inject depends on structure
|
191
191
|
def _depends_on(*args)
|
192
|
-
_set(
|
192
|
+
_set("depends_on", [args].flatten.compact.map { |s| __attribute_key(s) })
|
193
193
|
end
|
194
194
|
|
195
195
|
alias_method :depends_on!, :_depends_on
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "sparkle_formation"
|
2
2
|
|
3
3
|
class SparkleFormation
|
4
4
|
|
@@ -15,7 +15,7 @@ class SparkleFormation
|
|
15
15
|
|
16
16
|
def _var(v_name)
|
17
17
|
__t_stringish(v_name)
|
18
|
-
res = ::SparkleFormation::TerraformStruct.new(
|
18
|
+
res = ::SparkleFormation::TerraformStruct.new("var").set!(__attribute_key(v_name))
|
19
19
|
end
|
20
20
|
|
21
21
|
alias_method :var!, :_var
|
@@ -23,27 +23,27 @@ class SparkleFormation
|
|
23
23
|
|
24
24
|
def _path(p_name)
|
25
25
|
__t_stringish(p_name)
|
26
|
-
::SparkleFormation::TerraformStruct.new(
|
26
|
+
::SparkleFormation::TerraformStruct.new("path").set!(__attribute_key(p_name))
|
27
27
|
end
|
28
28
|
|
29
29
|
alias_method :path!, :_path
|
30
30
|
|
31
31
|
def _module(m_name)
|
32
32
|
__t_stringish(m_name)
|
33
|
-
::SparkleFormation::TerraformStruct.new(
|
33
|
+
::SparkleFormation::TerraformStruct.new("module").set!(__attribute_key(m_name))
|
34
34
|
end
|
35
35
|
|
36
36
|
alias_method :module!, :_module
|
37
37
|
|
38
38
|
def _terraform_self(s_name)
|
39
39
|
__t_stringish(s_name)
|
40
|
-
::SparkleFormation::TerraformStruct.new(
|
40
|
+
::SparkleFormation::TerraformStruct.new("self").set!(__attribute_key(s_name))
|
41
41
|
end
|
42
42
|
|
43
43
|
alias_method :self!, :_terraform_self
|
44
44
|
|
45
45
|
def _terraform_lookup(*args)
|
46
|
-
::SparkleFormation::TerraformStruct.new(
|
46
|
+
::SparkleFormation::TerraformStruct.new("lookup", *args)
|
47
47
|
end
|
48
48
|
|
49
49
|
alias_method :lookup!, :_terraform_lookup
|
@@ -58,38 +58,38 @@ class SparkleFormation
|
|
58
58
|
alias_method :resource!, :_resource
|
59
59
|
|
60
60
|
TERRAFORM_INTRINSIC_FUNCTIONS = [
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
61
|
+
"base64decode",
|
62
|
+
"base64encode",
|
63
|
+
"base64sha256",
|
64
|
+
"cidrhost",
|
65
|
+
"cidrnetmask",
|
66
|
+
"cidrsubnet",
|
67
|
+
"coalesce",
|
68
|
+
"compact",
|
69
|
+
"concat",
|
70
|
+
"distinct",
|
71
|
+
"element",
|
72
|
+
"file",
|
73
|
+
"format",
|
74
|
+
"formatlist",
|
75
|
+
"index",
|
76
|
+
"join",
|
77
|
+
"jsonencode",
|
78
|
+
"length",
|
79
|
+
"list",
|
80
|
+
"lower",
|
81
|
+
"map",
|
82
|
+
"md5",
|
83
|
+
"merge",
|
84
|
+
"uuid",
|
85
|
+
"replace",
|
86
|
+
"sha1",
|
87
|
+
"sha256",
|
88
|
+
"signum",
|
89
|
+
"sort",
|
90
|
+
"split",
|
91
|
+
"trimspace",
|
92
|
+
"upper",
|
93
93
|
]
|
94
94
|
|
95
95
|
# NOTE: Alias implementation disabled due to Ruby 2.3 __callee__ bug
|
@@ -100,7 +100,7 @@ class SparkleFormation
|
|
100
100
|
# @return [SparkleFormation::FunctionStruct]
|
101
101
|
def _fn_format(*args)
|
102
102
|
src = ::Kernel.__callee__.to_s
|
103
|
-
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/,
|
103
|
+
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/, ""), false)
|
104
104
|
::SparkleFormation::TerraformStruct.new(src, *args)
|
105
105
|
end
|
106
106
|
|
@@ -112,7 +112,7 @@ class SparkleFormation
|
|
112
112
|
|
113
113
|
define_method("_#{f_name}".to_sym) do |*args|
|
114
114
|
src = ::Kernel.__callee__.to_s
|
115
|
-
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/,
|
115
|
+
src = ::Bogo::Utility.camel(src.sub(/(^_|\!$)/, ""), false)
|
116
116
|
::SparkleFormation::TerraformStruct.new(src, *args)
|
117
117
|
end
|
118
118
|
alias_method "#{f_name}!".to_sym, "_#{f_name}".to_sym
|
@@ -137,7 +137,7 @@ class SparkleFormation
|
|
137
137
|
# @return [Array<String>]
|
138
138
|
# @note this will directly modify the struct at its current context to inject depends on structure
|
139
139
|
def _depends_on(*args)
|
140
|
-
_set(
|
140
|
+
_set("depends_on", [args].flatten.compact.map { |s| __attribute_key(s) })
|
141
141
|
end
|
142
142
|
|
143
143
|
alias_method :depends_on!, :_depends_on
|