dh-proteus 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/proteus/modules/manager.rb +32 -1
- data/lib/proteus/templates/partial.rb +2 -5
- data/lib/proteus/version.rb +1 -1
- 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: b0f118c08e97393ebe12d2864e0619d473e3bcc11acafadc69c4d4af472cc5bb
|
4
|
+
data.tar.gz: 7d3b468f8b7f6a66e5d423381f907ef052af46db873bc556b8e866ddd9dc8c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9940ad762af1654002ebee65755f2d4780a9733b7cb620c23b7dfb56af9474a1846629170232821c4472e9e4f01dd2d9cc4e80f78bf38aa1569d71b9510c6b2e
|
7
|
+
data.tar.gz: feee98574ec54314a3e078862ae95bf7a8ae3598fb7a04c3fcad191fd5a617dd1f19c54afc98df029f85afc6f4fde8af35cf77d0c8bbf58ae96c6f4aefc37d59
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'proteus/helpers/path_helpers'
|
2
2
|
require 'proteus/modules/terraform_module'
|
3
3
|
require 'proteus/backend/backend'
|
4
|
+
require 'proteus/modules/defaults_parser'
|
5
|
+
require 'json'
|
4
6
|
|
5
7
|
module Proteus
|
6
8
|
module Modules
|
@@ -33,7 +35,7 @@ module Proteus
|
|
33
35
|
if tfvars_content.empty?
|
34
36
|
terraform_variables = []
|
35
37
|
else
|
36
|
-
terraform_variables =
|
38
|
+
terraform_variables = JSON.parse(parse_tfvars(tfvars: tfvars_content))
|
37
39
|
end
|
38
40
|
|
39
41
|
@modules = []
|
@@ -48,6 +50,35 @@ module Proteus
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
53
|
+
def parse_tfvars(tfvars:)
|
54
|
+
lines = tfvars.split("\n")
|
55
|
+
lines.reject! {|l| l.empty? || l.match(/#/) }
|
56
|
+
substituted_lines = []
|
57
|
+
|
58
|
+
lines.each_with_index do |line, index|
|
59
|
+
next_line = lines[index + 1] || ""
|
60
|
+
|
61
|
+
# insert comma after closing bracket and curly brace
|
62
|
+
if line =~ /\]$|\}$/ && index != lines.size-1
|
63
|
+
substituted_lines << "#{line},"
|
64
|
+
else
|
65
|
+
if index == lines.size-1 || line =~ /\[|\{/ || next_line =~ /\]|\}/
|
66
|
+
substituted_lines << line.gsub(/([a-z0-9_]+)( *=)(.*)/, "\"\\1\": \\3")
|
67
|
+
if substituted_lines.last =~ /,$/ && next_line =~ /\]|\}/
|
68
|
+
substituted_lines.last.gsub!(/,$/, "")
|
69
|
+
end
|
70
|
+
else
|
71
|
+
if line =~ /=/
|
72
|
+
substituted_lines << line.gsub!(/([a-z0-9_]+)( *=)(.*)/, "\"\\1\": \\3,")
|
73
|
+
else
|
74
|
+
substituted_lines << line
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
"{\n#{substituted_lines.join("\n")}\n}"
|
81
|
+
end
|
51
82
|
end
|
52
83
|
end
|
53
84
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'hcl/checker'
|
2
|
-
|
3
1
|
module Proteus
|
4
2
|
module Templates
|
5
3
|
class Partial < TemplateBinding
|
@@ -24,10 +22,10 @@ module Proteus
|
|
24
22
|
|
25
23
|
if data.dig('partials', @name)
|
26
24
|
@partial_data_present = true
|
27
|
-
|
28
25
|
@data['partials'][@name].delete('render')
|
29
|
-
|
30
26
|
set(@name, @data['partials'][@name])
|
27
|
+
else
|
28
|
+
set(@name, ActiveSupport::HashWithIndifferentAccess.new)
|
31
29
|
end
|
32
30
|
|
33
31
|
end
|
@@ -45,7 +43,6 @@ module Proteus
|
|
45
43
|
partial_file = sub_directory_partial_path
|
46
44
|
end
|
47
45
|
|
48
|
-
|
49
46
|
if File.file?(partial_file)
|
50
47
|
partial_template = File.read(partial_file)
|
51
48
|
|
data/lib/proteus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dh-proteus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Albrecht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|