terraform-synthesizer 0.0.20 → 0.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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/terraform-synthesizer/version.rb +1 -1
- data/lib/terraform-synthesizer.rb +9 -46
- data/spec/terraform_spec.rb +19 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14d574d872c1ac1022a494d9372734fc616f296d8bcb0aecbb2e047688eec02
|
4
|
+
data.tar.gz: 11e5d148dbcb7098c6b5ac2486bd9ec259a634a47967af32c9dde2465f709a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5fe4bb12900049eb30fae229cc92afdacae4d4d774095429a839688bed8cc5f1e7e480d80174a03819f0a4d055886bd272aa902b19bfb7a4f82d050fdf22c94
|
7
|
+
data.tar.gz: 4912d72d0f65b7857955e157537cadb5b41162a3e9d1ea788647ce9c1527d61f8a63214f0f894826f2e37c6c90332ebc668ccef7d876d2e952dc9dcfe9437b88
|
data/Gemfile.lock
CHANGED
@@ -44,7 +44,7 @@ GEM
|
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
45
|
rspec-support (~> 3.12.0)
|
46
46
|
rspec-support (3.12.1)
|
47
|
-
rubocop (1.
|
47
|
+
rubocop (1.58.0)
|
48
48
|
json (~> 2.3)
|
49
49
|
language_server-protocol (>= 3.17.0)
|
50
50
|
parallel (~> 1.10)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
rainbow (>= 2.2.2, < 4.0)
|
53
53
|
regexp_parser (>= 1.8, < 3.0)
|
54
54
|
rexml (>= 3.2.5, < 4.0)
|
55
|
-
rubocop-ast (>= 1.
|
55
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
56
56
|
ruby-progressbar (~> 1.7)
|
57
57
|
unicode-display_width (>= 2.4.0, < 3.0)
|
58
58
|
rubocop-ast (1.30.0)
|
@@ -2,57 +2,20 @@ require %(abstract-synthesizer)
|
|
2
2
|
|
3
3
|
class TerraformSynthesizer < AbstractSynthesizer
|
4
4
|
RESOURCE_KEYS = %i[
|
5
|
+
terraform
|
6
|
+
provider
|
5
7
|
resource
|
6
8
|
variable
|
9
|
+
locals
|
7
10
|
output
|
8
11
|
data
|
9
12
|
].freeze
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# notes:
|
18
|
-
#
|
19
|
-
# locals are processed as a direct block like
|
20
|
-
# locals do
|
21
|
-
# key value
|
22
|
-
# end
|
23
|
-
# while resources are processed as resource like blocks
|
24
|
-
# resource :aws_vpc, :virtual_name do
|
25
|
-
# key value
|
26
|
-
# end
|
27
|
-
##############################################################################
|
28
|
-
def method_missing(method_name, *args, &)
|
29
|
-
BLOCK_KEYS.each do |block_key|
|
30
|
-
if @in_block_key
|
31
|
-
if args[0].nil? || args[0].empty?
|
32
|
-
raise ArgumentError,
|
33
|
-
%(not assigning anything to this #{block_key})
|
34
|
-
end
|
35
|
-
|
36
|
-
@in_block_key = false
|
37
|
-
@translation[:template][block_key.to_sym][method_name.to_sym] = args[0]
|
38
|
-
|
39
|
-
elsif method_name.to_s.eql?(block_key.to_s)
|
40
|
-
|
41
|
-
@translation = {} if @translation.nil?
|
42
|
-
@translation[:template] = {} if @translation[:template].nil?
|
43
|
-
@translation[:template][block_key.to_sym] = {} \
|
44
|
-
if @translation[:template][block_key.to_sym].nil?
|
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
|
56
|
-
end
|
14
|
+
def method_missing(method_name, ...)
|
15
|
+
abstract_method_missing(
|
16
|
+
method_name.to_sym,
|
17
|
+
RESOURCE_KEYS,
|
18
|
+
...
|
19
|
+
)
|
57
20
|
end
|
58
21
|
end
|
data/spec/terraform_spec.rb
CHANGED
@@ -6,43 +6,37 @@ describe TerraformSynthesizer do
|
|
6
6
|
described_class.new
|
7
7
|
end
|
8
8
|
|
9
|
-
it %(should
|
9
|
+
it %(should contain resource thing) do
|
10
10
|
synth.synthesize do
|
11
11
|
resource :aws_vpc, :thing do
|
12
12
|
cidr_block %(10.0.0.0/16)
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
stuff do
|
14
|
+
other_stuff %(whoa)
|
15
|
+
end
|
16
16
|
end
|
17
17
|
resource :aws_vpc, :thang do
|
18
18
|
cidr_block %(10.0.0.0/16)
|
19
19
|
end
|
20
20
|
end
|
21
|
-
expect(synth.synthesis).to be_kind_of(Hash)
|
21
|
+
expect(synth.synthesis[:resource][:aws_vpc][:thing]).to be_kind_of(Hash)
|
22
22
|
end
|
23
23
|
|
24
|
-
it %(should
|
24
|
+
it %(should compile small declaration and be hash) do
|
25
25
|
synth.synthesize do
|
26
26
|
resource :aws_vpc, :thing do
|
27
27
|
cidr_block %(10.0.0.0/16)
|
28
28
|
end
|
29
|
-
locals do
|
30
|
-
special_var %(special_value)
|
31
|
-
end
|
32
29
|
resource :aws_vpc, :thang do
|
33
30
|
cidr_block %(10.0.0.0/16)
|
34
31
|
end
|
35
32
|
end
|
36
|
-
expect(synth.synthesis
|
33
|
+
expect(synth.synthesis).to be_kind_of(Hash)
|
37
34
|
end
|
38
35
|
|
39
|
-
it %(should contain
|
36
|
+
it %(should contain locals) do
|
40
37
|
synth.synthesize do
|
41
38
|
resource :aws_vpc, :thing do
|
42
39
|
cidr_block %(10.0.0.0/16)
|
43
|
-
stuff do
|
44
|
-
other_stuff %(whoa)
|
45
|
-
end
|
46
40
|
end
|
47
41
|
locals do
|
48
42
|
special_var %(special_value)
|
@@ -51,7 +45,7 @@ describe TerraformSynthesizer do
|
|
51
45
|
cidr_block %(10.0.0.0/16)
|
52
46
|
end
|
53
47
|
end
|
54
|
-
expect(synth.synthesis[:
|
48
|
+
expect(synth.synthesis[:locals][:special_var]).to be_kind_of(String)
|
55
49
|
end
|
56
50
|
|
57
51
|
it %(should contain resource thang) do
|
@@ -68,5 +62,15 @@ describe TerraformSynthesizer do
|
|
68
62
|
end
|
69
63
|
expect(synth.synthesis[:resource][:aws_vpc][:thang]).to be_kind_of(Hash)
|
70
64
|
end
|
65
|
+
|
66
|
+
it %(should return provider) do
|
67
|
+
synth.synthesize do
|
68
|
+
provider :datadog do
|
69
|
+
api_key %(api key value)
|
70
|
+
app_key %(app key value)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
expect(synth.synthesis[:provider]).to be_kind_of(Hash)
|
74
|
+
end
|
71
75
|
end
|
72
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraform-synthesizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drzthslnt@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abstract-synthesizer
|