terraform-synthesizer 0.0.15 → 0.0.17
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/lib/terraform-synthesizer/version.rb +1 -1
- data/lib/terraform-synthesizer.rb +43 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7f3d2d5097f859aca6b9b54eb06dd39b18e56413619087f8a63c022886dbe88
|
4
|
+
data.tar.gz: 636f94e4fa483d77ef9acfbc69a208b8aa939fa99b8a5f5184acc9f49e3805e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a0ccde1b6a9cf07603846f6eed12733d553082df504cb3967ac8843ff5b2a3bd5a5e789283e7403c7ec3e740910310c4421ad6aa8bc3597ab6bc33da49acd8
|
7
|
+
data.tar.gz: beec70098377f90991a3a11824de7c73876efe3d9f82e048102689a68ea94eb5502bbbb92f9ab62c226d04bba4ed618ba74803860dbd835468cf77ca9ba36c7e
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require %(abstract-synthesizer)
|
2
2
|
|
3
3
|
class TerraformSynthesizer < AbstractSynthesizer
|
4
|
-
|
4
|
+
RESOURCE_KEYS = %i[
|
5
5
|
terraform
|
6
6
|
resource
|
7
7
|
variable
|
@@ -9,28 +9,50 @@ class TerraformSynthesizer < AbstractSynthesizer
|
|
9
9
|
data
|
10
10
|
].freeze
|
11
11
|
|
12
|
+
# if there are additional block keys
|
13
|
+
# add them here and they should be processed
|
14
|
+
# accordingly
|
15
|
+
BLOCK_KEYS = %i[locals].freeze
|
16
|
+
|
17
|
+
##############################################################################
|
18
|
+
# notes:
|
19
|
+
#
|
20
|
+
# locals are processed as a direct block like
|
21
|
+
# locals do
|
22
|
+
# key value
|
23
|
+
# end
|
24
|
+
# while resources are processed as resource like blocks
|
25
|
+
# resource :aws_vpc, :virtual_name do
|
26
|
+
# key value
|
27
|
+
# end
|
28
|
+
##############################################################################
|
12
29
|
def method_missing(method_name, *args, &)
|
13
|
-
|
14
|
-
if
|
15
|
-
raise ArgumentError,
|
16
|
-
|
17
|
-
|
30
|
+
BLOCK_KEYS.each do |block_key|
|
31
|
+
if @in_block_key
|
32
|
+
raise ArgumentError, %(not assigning anything to this #{block_key}) if args[0].nil? || args[0].empty?
|
33
|
+
|
34
|
+
@in_block_key = false
|
35
|
+
@translation[:template][block_key.to_sym][method_name.to_sym] = args[0]
|
18
36
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
elsif method_name.to_s.eql?(block_key.to_s)
|
38
|
+
|
39
|
+
@translation = {} if @translation.nil?
|
40
|
+
@translation[:template] = {} if @translation[:template].nil?
|
41
|
+
if @translation[:template][block_key.to_sym].nil?
|
42
|
+
@translation[:template][block_key.to_sym] =
|
43
|
+
{}
|
44
|
+
end
|
45
|
+
@in_block_key = true
|
46
|
+
|
47
|
+
yield
|
48
|
+
else
|
49
|
+
abstract_method_missing(
|
50
|
+
method_name.to_sym,
|
51
|
+
RESOURCE_KEYS,
|
52
|
+
*args,
|
53
|
+
&
|
54
|
+
)
|
55
|
+
end
|
34
56
|
end
|
35
57
|
end
|
36
58
|
end
|