terraform-synthesizer 0.0.11 → 0.0.13
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 +26 -16
- data/spec/terraform_spec.rb +54 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc883c7ad48c980209e3d0b395b119c05ea5823efc2bef68fbfe4ee06b0ce46
|
4
|
+
data.tar.gz: 91ae2362eec2166aad30d1dede5592df49aa9e8cc2af25d948af83ec68b40895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6b7ff9dd1381cd91bc593edb78ce38a44ea2ea0bc4bd90f3f0159ad84189c08bdb1e85dc82a04e670de327f2dafce870245e53ae9cc94a01628dd9d1b9c769
|
7
|
+
data.tar.gz: f85c3c0d25801e545910aed10c44abdcbd33c131f49acecaf13c11e3f54f7100a5f043996d4b6893fc91f6522918781b1b972925fa9e63a143971aa06663bc69
|
@@ -1,35 +1,45 @@
|
|
1
1
|
require %(abstract-synthesizer)
|
2
2
|
|
3
3
|
class TerraformSynthesizer < AbstractSynthesizer
|
4
|
-
|
4
|
+
KEYS = %i[
|
5
|
+
terraform
|
6
|
+
resource
|
7
|
+
variable
|
8
|
+
output
|
9
|
+
data
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def method_missing(method_name, *args, &)
|
5
13
|
if @in_locals
|
14
|
+
puts %(processing local variable #{method_name})
|
15
|
+
puts %(processing local variable value #{args[0]})
|
6
16
|
if args[0].nil?
|
7
17
|
raise ArgumentError,
|
8
18
|
%(not assigning anything to this local #{method_name})
|
9
19
|
end
|
10
20
|
|
11
|
-
@translation[:template][:locals][method_name.to_sym] = args[0]
|
12
21
|
@in_locals = false
|
13
|
-
|
14
|
-
|
22
|
+
@translation[:template][:locals].merge!(
|
23
|
+
{ method_name.to_sym => args[0] }
|
24
|
+
)
|
25
|
+
elsif method_name.to_s.eql?(%(locals))
|
26
|
+
puts %(caught local execution start)
|
27
|
+
|
15
28
|
@translation = {} if @translation.nil?
|
29
|
+
puts @translation
|
16
30
|
@translation[:template] = {} if @translation[:template].nil?
|
31
|
+
puts @translation
|
17
32
|
@translation[:template][:locals] = {} if @translation[:template][:locals].nil?
|
18
|
-
@translation
|
33
|
+
puts @translation
|
19
34
|
@in_locals = true
|
35
|
+
puts @translation
|
36
|
+
yield
|
20
37
|
else
|
21
|
-
return {} if @in_locals
|
22
|
-
|
23
38
|
abstract_method_missing(
|
24
|
-
method_name,
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
variable
|
29
|
-
output
|
30
|
-
data
|
31
|
-
],
|
32
|
-
...
|
39
|
+
method_name.to_sym,
|
40
|
+
KEYS,
|
41
|
+
*args,
|
42
|
+
&
|
33
43
|
)
|
34
44
|
end
|
35
45
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require %(terraform-synthesizer)
|
2
|
+
|
3
|
+
describe TerraformSynthesizer do
|
4
|
+
context %(main) do
|
5
|
+
let(:synth) do
|
6
|
+
described_class.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it %(should compile small declaration and be hash) do
|
10
|
+
synth.synthesize do
|
11
|
+
resource :aws_vpc, :thing do
|
12
|
+
cidr_block %(10.0.0.0/16)
|
13
|
+
end
|
14
|
+
locals do
|
15
|
+
special_var %(special_value)
|
16
|
+
end
|
17
|
+
resource :aws_vpc, :thang do
|
18
|
+
cidr_block %(10.0.0.0/16)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
expect(synth.synthesis).to be_kind_of(Hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
it %(should contain locals) do
|
25
|
+
synth.synthesize do
|
26
|
+
resource :aws_vpc, :thing do
|
27
|
+
cidr_block %(10.0.0.0/16)
|
28
|
+
end
|
29
|
+
locals do
|
30
|
+
special_var %(special_value)
|
31
|
+
end
|
32
|
+
resource :aws_vpc, :thang do
|
33
|
+
cidr_block %(10.0.0.0/16)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
expect(synth.synthesis[:locals][:special_var]).to be_kind_of(String)
|
37
|
+
end
|
38
|
+
|
39
|
+
it %(should contain resources) do
|
40
|
+
synth.synthesize do
|
41
|
+
resource :aws_vpc, :thing do
|
42
|
+
cidr_block %(10.0.0.0/16)
|
43
|
+
end
|
44
|
+
locals do
|
45
|
+
special_var %(special_value)
|
46
|
+
end
|
47
|
+
resource :aws_vpc, :thang do
|
48
|
+
cidr_block %(10.0.0.0/16)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
expect(synth.synthesis[:resource][:aws_vpc][:thing]).to be_kind_of(Hash)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drzthslnt@gmail.com
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- gemset.nix
|
46
46
|
- lib/terraform-synthesizer.rb
|
47
47
|
- lib/terraform-synthesizer/version.rb
|
48
|
+
- spec/terraform_spec.rb
|
48
49
|
- terraform-synthesizer.gemspec
|
49
50
|
homepage: https://github.com/drzln/terraform-synthesizer
|
50
51
|
licenses:
|